In the centre of the Circuit Playground, to the left and right of the accelerometer is the infrared (IR) transmitter and receiver. Using IR to communicate on the Circuit Playground is easy! We use the network block to select a number to transmit, and a network block to receive numbers and store them as a variable. We can also send variables that are stored as numbers, such as RGB colours. Most of what happens when we send an IR signal happens behind the scenes.

Transcript

Welcome back to the Circuit Playground Express, online workshop in this section we're going to learn about infrared transmitting and receiving on the Circuit Playground Express.

So, we'll create a simple sketch, where when we push a button on the board it'll transmit an infrared signal, that another Circuit Playground will receive and play a rainbow animation. So, at the centre of every Circuit Playground Express, we have a small infrared LED in a small infrared receiver. So when we want to transmit an infrared signal from onboard we create a command and we can send any number through MakeCode over infrared and the Circuit Playground encodes that into a series of pulses of infrared light and the receiving Circuit Playground measures the duration of time that passes between each pulse and then decodes it back into whatever number you set so even if you're going to send just the number one the Circuit Playground is going to send 52 pulses of infrared light and then the receiving Circuit Playground is going to decode that back into the number 1 and all this happens in just a fraction of a second.

So, let's look at it in MakeCode. Under the network option, we have our infrared commands which is the infrared send an infrared receive. So the simplest way to use infrared is just with a button click so when we click the button will send the number 0 which is the default number but you can enter any decimal number that you'd like in there or you can even send a colour for LEDs because that's stored as a number as well. So, we also have the infrared receive option, which is what we use to turn on the receiver to look for signals in infrared and whenever we receive a number in the infrared it's going to store it as the variable number by default and we can change the variable, but we'll stick with number for now. So, it stores it as the variable and then we can use that variable as I have here in some logic to create a command when we have a signal so you can that allow you to receive any number of different numbers if I may have different factions within your code.

So, when I push button A it sends a zero when it receives when it receives a signal it checks to see if that signals are zero and then if it is it plays an animation for two seconds. So let's take a look again when I press the button on one board the other board receives it and it plays a rainbow animation and with this code that I have loaded it could sit you could both send in receive from both boards you're not limited to doing one on one action on one and one action on the other.

So that wraps up how to use the infrared transmitting and receiving there's a lot of potential with that system you can even communicate with household devices over infrared but this is the easiest way to do it from Circuit Playground to Circuit Playground stick around in the next section we're going to learn about how to turn your Circuit Playground into a keyboard or a mouse. Welcome back to the Circuit Playground Express, online workshop in this section we're going to learn about infrared transmitting and receiving on the Circuit Playground Express.

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.