Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.

IR Proximity Sensor on CPX Using Arduino
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

IR Proximity Sensor on CPX Using Arduino

by gullydwarf on Mon Aug 10, 2020 7:13 pm


I am trying to get the CPX to act like a proximity sensor. Transmit IR and then receive IR and turn on some lights. I am cribbing some code by taking screen shots of the background from this #DeskOfLadyada You Tube video:

It seems like I made a few of the right pin changes from what she had but I just cannot figure out how to get the IR measurements from A10. The CPX documentation says A10 is the IR Proximity. It seems like it should use D26 - the IR Receiver.

Do I need to set the IR Rx to High to take in light and then get the measurement from A10? Do I set the Tx and RX to high at the same time and measure A10 then? I feel like I have tried a lot of variations and maybe I am just not coding the address right.

So far I have this:

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_Circuit_Playground.h>
//#include <Adafruit_NeoPixel.h>

#define IR_TX_PIN 25
#define PROX_PIN A10
#define IR_RX_PIN 26

void setup() {
  // Initialize the circuit playground

  while (!Serial);

  pinMode(IR_TX_PIN, OUTPUT);
  pinMode(IR_RX_PIN, INPUT);
  digitalWrite(IR_TX_PIN, LOW);
  digitalWrite(IR_RX_PIN, LOW);

void loop() {
  digitalWrite(IR_TX_PIN, HIGH);
  digitalWrite(IR_TX_PIN, LOW);
  //digitalWrite(IR_RX_PIN, HIGH);
  int prox = analogRead(PROX_PIN);
  //digitalWrite(IR_RX_PIN, LOW);


The Serial Monitor is getting some kind of measurement from A10 but it does not change. Some of the commented out lines in the Loop Function is me trying to experiment to get a measurement.

Perhaps the larger issue is trying to use Arduino to manipulate the different built in sensors on the PGX. Most of the examples and documentation online assume CircuitPython or MakeCode, so maybe I am missing something in the translation?

Thank you for any consideration of this question.
Prox3.jpg (67.12 KiB) Viewed 24 times
Prox1.jpg (69.06 KiB) Viewed 24 times
Prox2.jpg (67 KiB) Viewed 24 times

Posts: 2
Joined: Mon Aug 10, 2020 6:44 pm

Re: IR Proximity Sensor on CPX Using Arduino

by petespaco on Sun Aug 16, 2020 7:18 pm

I sure hope somebody can help.
I'd like to a similar thing with the !R stuff on the CPX, using the Arduino IDE, as well, but I didn't even get as far as coding. All I want to do is to be able to push a button and get a reading to show up on the Gizmo.

Pete Stanaitis

Posts: 95
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Please be positive and constructive with your questions and comments.