So far we have only used the receiver portion of the IR capabilities of the Circuit Playground Express. But we also have the ability to transmit IR codes using the built-in IR LED. Here is an extremely simple example that sends a signal whenever you push one of the buttons on the Circuit Playground Express. This example is set up for my Samsung TV using NECx protocol but you can substitute protocol and code values for your remote. Use the Infrared_Read example to figure out the codes for your TV remote.

/* Infrared_Send.ino Example sketch for IRLib2 and Circuit Playground Express
   Illustrates how to transmit an IR signal whenever you do push one of the
   built-in pushbuttons.
#include <Adafruit_CircuitPlayground.h>

  #error "Infrared support is only for the Circuit Playground Express, it doesn't work with the Classic version"

void setup() {

//Defines for a Samsung TV using NECx protocol
#define MY_BITS 32
#define MY_MUTE 0xE0E0F00F
#define MY_POWER 0xE0E040BF

void loop() {
  // If the left button is pressed send a mute code.
  if (CircuitPlayground.leftButton()) {
    while (CircuitPlayground.leftButton()) {}//wait until button released
  // If the right button is pressed send a power code.
  if (CircuitPlayground.rightButton()) {
    while (CircuitPlayground.rightButton()) {}//wait until button released

Upload the sketch using the Arduino IDE. Point the front of your Circuit Playground Express at your TV. When you press the left button it should mute your TV. When you press the right button it will toggle the power. Again we remind you you may have to substitute different protocols and codes for your TV.

Note that after we send the data, we wait until the button is released so that it doesn't repeatedly send the code over and over again.

You could expand this example to add other functions perhaps using the capacitive touch features of the Circuit Playground Express.

This guide was first published on Jul 27, 2017. It was last updated on Mar 08, 2024.

This page (Infrared_Send) was last updated on Jul 01, 2017.

Text editor powered by tinymce.