When you’ve soldered the resistors and connecting wire in place, flip the screwshield over to solder the underside of the board.
Figure 8-10 shows a close-up of the underside of the screwshield. To make it easier to identify what is connected to what, the resistors and linking wire are shown as if they were visible through the board.
Figure 8-10: Connecting the underside of the screwshield
First, bend the bottom lead of the 270 Ω resistor over toward the bottom pin header ➊. Solder this to the bottom pin header’s pad and snip off the remaining lead. Bend the remaining lead from the bottom end of the 470 Ω resistor to meet the pad one position to its left ➋. Solder the lead to that pad and snip off the excess lead. You have now made a continuous connection from the bottom of the header pins to the bottoms of the 270 Ω resistor and the 470 Ω resistor.
The final connection on the underside ➌ uses the spare wire from soldering the lead from the jumper wire to the header pin to its immediate left.
STEP 3: SOLDERING THE BLUETOOTH MODULE
The final step is to solder the Bluetooth module to the header pins. Solder one pad on the module to one of the header pins, and while keeping the solder molten, position the Bluetooth module so that it is resting against the 1 kΩ resistor that came attached to the screwshield. Then attach the first prong of the module to the first pin. You can see this resistor on the bottom right of Figure 8-9. Once the first prong is soldered, all the other prongs should be lined up and easy to solder. If you prefer, you could use female-to-female jumper wires to link the screwshield to the Bluetooth module. Figure 8-11 shows the Bluetooth module in position.
Figure 8-11: The Bluetooth module soldered in position
SOFTWARE
Since your sensors aren’t changing, you’ll use the same Arduino software as in “Arduino Software” on page 143. The Bluetooth module replaces the USB interface.
Note that this hardware communicates with the Bluetooth module using the serial port, which on an Arduino Uno is shared with the USB interface. This means that you need to unplug the shield (or just the Bluetooth module if you used jumper wires) before you program the Arduino.
The Raspberry Pi software, however, does need a couple of minor changes, and getting the Raspberry Pi to use Bluetooth does require you to install a whole load of software. Remember: You’ll need to install this software before the Internet fails!
Plug the Bluetooth USB adapter into a free USB slot on your Raspberry Pi and then run the following commands in an LXTerminal window:
$ sudo apt-get update
$ sudo apt-get install bluetooth
$ sudo apt-get install bluez-utils
$ sudo apt-get install blueman
Installing the software will take a considerable amount of time, so you might want to practice your martial arts skills on any willing humans or unwilling zombies available.
When the software is installed and you’ve worked up a good sweat, reboot the Raspberry Pi with this command:
$ sudo reboot
Once the Raspberry Pi has rebooted, open a terminal and run the following command to ascertain the ID of the BT interface:
$ hciconfig
➊ hci0: Type: BR/EDR Bus: USB
BD Address: 00:15:83:0C:BF:EB ACL MTU: 339:8 SCO MTU: 128:2
UP RUNNING PSCAN
RX bytes:419213 acclass="underline" 19939 sco:0 events:7407 errors:0
TX bytes:95875 acclass="underline" 7321 sco:0 commands:57 errors:0
The information we want here is the name of the interface, which in this case is hci0 at ➊. When you run this, if the number after hci above is not 0, then make a note of the number; you will need it later.
Every Bluetooth device has a unique ID called a MAC address. We need to find the MAC address for our new Arduino Bluetooth module to pair it with the Raspberry Pi. When you power up the Arduino, you should see an LED blinking on the Bluetooth module. The LED is blinking because it has not yet been paired up with the Raspberry Pi; once it has been paired, the LED will go on and stay on. Run the following command to find the ID of the Bluetooth module:
$ hcitool scan
The output from the hcitool command should look like this:
Scanning ...
00:11:04:08:04:76 linvor
The ID is the six-part number. Copy this into the copy-and-paste buffer (Copy and Paste are on the right-click menu). Then enter the following command to link the Raspberry Pi and the Bluetooth module (remember to change the Bluetooth ID to match your Bluetooth module’s ID):
$ sudo hcitool cc 00:11:04:08:04:76
If you have not already done so, follow the instructions in “Raspberry Pi Software” on page 145 for downloading the Raspberry Pi software. You will find the Bluetooth version of control.py in the folder Raspberry Pi/control_center_bt.
When you have the program, run the following sudo command, again replacing the Bluetooth ID with your own:
$ sudo rfcomm connect 0 00:11:04:08:04:76 1 &
[1] 2625
$ Connected /dev/rfcomm0 to 00:11:04:08:04:76 on channel 1
Press CTRL-C for hangup
$
You’ll need to run this command before you run the program each time your Raspberry Pi reboots. The & on the end of the command runs it in the background so that you can use the terminal window to run the program itself. Hit ENTER to get the $ command prompt back.
If your Bluetooth interface name did not have a 0 after hci when you ran the hciconfig command earlier, change the first 0 after connect to match the number on the end of hci. Remember when I asked you to make a note of this number?
Finally, move to the project directory and run the program:
$ cd ~/zombies/control_center_bt/
$ python control.py
If you look at the control.py files from this project and Project 13, you can see that the only difference is the port. In this version of control.py, we set the port to /dev/rfcomm0 rather than /dev/ttyACM0 so that it uses the Bluetooth connection rather than the USB connection.
USING THE BLUETOOTH-ENABLED COMMAND CENTER
The project works in exactly the same way as the USB version in Project 13, with the window displaying the same information, only now it’s a little more portable as long as your webcam is wireless. If zombies get into your compound, just grab the Raspberry Pi, monitor, and power source and barricade yourself inside a closet until they lose interest.
In the next chapter, we’ll work on ways to distract zombies in a pinch, because the undead are usually much easier to run from than they are to actually kill.
9
ZOMBIE DISTRACTORS
It doesn’t take much to fool a zombie so you can make a quick escape (see Figure 9-1). They are rather lacking in brains, after all. The projects in this chapter are designed to draw zombies’ attention away from you using flashes of light, loud sounds, and decoy movements. Imagine you have a herd of zombies lurching around the garage door but you need to get to your last remaining car battery. These distractors will allow you to draw the zombies away from the door or even lure them into a fatal zombie trap, perhaps involving fire and a big hole in the ground.