Rather than dropping the boat to trigger the servo to start moving, an extra Circuit Playground Express can be used as a remote controller to tell it when to move.

This example uses the IR transmitter and receiver to send and receive an infrared signal.

In the image below, the transmitter is the big clear LED on the left, and the darker receiver LED on the right will receive the 38KHz signals and demodulate them for you.

Code for the Boat

In this MakeCode example, the directions telling the rudder to flap are moved into a function which can be called when either the boat is dropped OR when CPX receives an infrared signal.

Code for the Remote Controller

The second Circuit Playground Express will be used as the remote control. This needs only a simple function in MakeCode, telling it to send an infrared signal when a button is pressed. 

Infrared light is invisible to the human eye, so this function includes instructions to briefly flash the NeoPixels on the board white when it sends the signal, allowing the user to see that CPX has properly received and executed its instructions. 

Test out your remote control on your boat. Pressing the A button should trigger your boat to start swimming!

Luckily, infrared light isn't impeded by a layer of plastic, so you can keep your battery and electronics safe in a clear plastic bag. But keep in mind, the two boards must have a visible line of sight to each other, and be careful to avoid accidentally covering the IR component on the board with your fingers. 

This guide was first published on Mar 15, 2019. It was last updated on Mar 15, 2019.

This page (MakeCode Level 2: Remote Control) was last updated on Mar 06, 2019.

Text editor powered by tinymce.