Talking With Infrared

There is already an excellent guide that goes over the basics of using the Circuit Playground Express to receive and transmit information using the built in infrared hardware. Check it out by following the link below.

To summarize, the key Circuit Playground Express feature we will use is the infrared transmitter and receiver pair.

The IR transmitter and receiver on the Circuit Playground Express can be found near the center of the board.

 

The transmitter is labeled TX and is on the left side of the reset button, to the right of button A. The receiver is labeled RX and is on the right side of the reset button, to the left of button B.

For each of our "treasures", we will use the IR transmitter to send out a unique ID number. These numbers don't need to be fancy, so we will just use 1, 2, 3, etc. For the "hunter", we use the IR receiver to listen for any incoming signals. When one comes in, we check the number and see if it's one of the missing treasure ID's. So, something like this:

The Hunter can keep track of how many Treasures have been found and give an indication of progress. When all of the Treasures are found, the Hunter will do a little victory dance of some kind.

Let's see how to do this using MakeCode and CircuitPython.

This guide was first published on Jul 26, 2018. It was last updated on Jul 26, 2018. This page (Talking With Infrared) was last updated on Jul 15, 2019.