Project: Wireless LED Activation
Oooh, wireless radios! Working with them sounds kind of intimidating. It’s actually not, and I’ll prove it. Let’s create a simple network (see Figure 4.5) that lets two Arduinos communicate. In this mini-project, you’ll create two identical assemblies, each consisting of an Arduino and XBee, along with a button and a LED. When you press the button on one assembly, the LED on the other one lights up, and vice versa! You can see how this project will give you a nice start toward building a wireless doorbell, which is the main project for this chapter.
FIGURE 4.5 Control LEDs with XBee-equipped Arduinos.
Follow these steps to assemble the XBee test platform:
- Solder the breakout boards—Solder up your XBee breakout boards if you haven’t already. Depending on your kit, this could mean simply soldering in some header pins. On other kits, however, you must solder in LEDs, capacitors, and so on.
- Connect the XBees to the breakout boards—Attach the XBees to their respective breakout boards. This typically involves simply plugging in the XBees’ pins to the appropriate holes in the breakout board. Just follow the directions that accompany your kit.
Attach to breadboards—Plug the breakout boards and XBees into the breadboards. You can see where to place it in Figure 4.6.
FIGURE 4.6 This diagram shows you how to create these XBee test modules.
Attach the pushbuttons, LEDs, and jumpers—Attach these items as follows (also shown in Figure 4.6):
- GND on the XBee goes to GND on the breadboard. Connect the GND bus of the breadboard to the GND port of the Arduino.
- +5V on the XBee goes to 5V on the Arduino.
- TX on the XBee goes to RX on the Arduino.
- RX on the XBee goes to TX on the Arduino.
- Connect a button to pin 8 on the Arduino; the other end connects to the GND bus.
You should end up with two identical units, and if you upload the Arduino code to both of them, they should work identically. Even cooler, the way the networks are set up, you could actually create three or more of these assemblies and they’ll all work the way you would expect. Press the button on one, and the LEDs on all the others will light up! It’s not super practical, to be sure, but it shows how easily you can set up an XBee network.