Program the Trigger Box

Board Definition

Now, you're ready to make your controller do something!

First, make sure your Arduino IDE is configured properly with the board definition of your packet radio Feather. Use this guide to get started and this page to configure the Board Manager and board definition. Make sure you can properly upload the example blink sketch found in the Arduino IDE under File > Examples > 01 Basics > Blink before moving on.

RadioHead Library

You'll need at least two of the same (identical!) packet radio Feather boards (e.g., RFM69HCW to RFM69HCW or LoRa RFM95 to LoRa RFM95, no mixing and matching) set to the same frequency in order to send and receive messages -- one board on its own is very lonely, and semi-useless :( 

Install the RadioHead library as shown here and then upload the RadioHead -> feather -> RadioHead69_RawDemo_TX example on one board and RadioHead -> feather -> RadioHead69_RawDemo_RX on the other. Open your serial port on one board and make sure that they're talking to each other properly.

OLED Library

You'll also need to download the OLED library for the Feather. Follow the directions here. Test out the example code as directed.

Trellis Library

Use this guide to install the Trellis library so that your Feather can read the keypad data and light up the LEDs. It's fun!

Encoder Library

The final library we'll need on the transmitter side of things is the Encoder library for reading the rotary encoder data. 

Encoders are tricky. Here's a great explanation from PJRC, if you'd like to learn more.

Install the Encoder library by going to the Library Manager in the Arduino IDE Sketch > Include Library... > Library Manager and typing "Encoder quad linear" in the search filter field. Click on the Encoder by Paul Stoffregen entry and then click "install".

The trigger box can be programmed to do just about anything, and the user interface can be set up any way you like it!

In this example, the transmitter code is set up to send out commands that can be received by any number of receiver units, which each have their own code to determine how to react. The rotary encoder allows you to select different banks of effects from a menu, with each bank holding up to 16 commands -- one per button on the Trellis keypad.

For example, choose the "Motors" menu item with the knob, then press the first button to turn a stepper motor. Press the second button to turn the motor in the opposite direction. Perhaps the fifth button turns on a water pump for a few seconds. 

This is all done by having a motor FeatherWing connected to a receiving packet radio Feather operating on the same frequency as the transmitter.

Then, you can rotate the knob on the transmitter to the "Radio" menu item. Now, each of the 16 buttons can be used to trigger a different song on a second receiver Feather with the Music Maker MP3 FeatherWing attached. 

Follow the link below to download the code for the project.

Ada_remoteFXTrigger_TX is the Arduino sketch for the transmitter, including a few example effects. Download this code, unzip it, and save the directory in your Arduino sketches directory. Open the sketch in Arduino, and then upload it to your transmitter Feather.

Ada_remoteFXTrigger_RX_motor is the code to use on the motor receiver unit.

Save this sketch as you did before, and upload it to your receiver Feather with Motor FeatherWing attached.Make sure you have the Adafruit Motor Shield V2 library installed -- more info on setting up your Motor FeatherWing can be found here in this guide.

If you're using the Power Relay FeatherWing, upload the Ada_remoteFXTrigger_lamp code to your Feather.

And, lastly, if you're driving remote NeoPixels, grab the Ada_remoteFXTrigger_RX_NeoPixel code and send it to your NeoPixel-encrusted Feather.

Last updated on 2017-05-01 at 08.10.05 PM Published on 2017-04-29 at 11.12.16 AM