The first part of the line (*/3) schedules the transmission to run every 3 minutes, 24 hours a day, 7 days a week. If you use a different sound file or frequency, you need to replace sound.wav with your filename and enter your chosen frequency. If your message is longer than 3 minutes, change */3 to the number of minutes you need it to be.
You only need to do this configuration once; the settings will stick even if the Pi is rebooted.
PROJECT 18: ARDUINO FM RADIO FREQUENCY HOPPER
After the zombie apocalypse strikes, your chances of survival will be increased by group living—that is, assuming no bite victims come inside and turn into zombies. Always be sure that everyone gets checked for zombie-infected wounds before you grant entry!
You’ll inevitably need to sleep or go on supply runs, and without someone to watch your back you’ll be vulnerable. (Not to mention the slow descent into insanity you’ll suffer from lack of human contact—and you thought zombies were crazy.) Therefore, you’ll likely benefit from having a few companions around. Other groups of survivors may already be trying to make contact by broadcasting their own radio messages, as we now are. In fact, another group might have bought or salvaged this book and made the FM transmitter of Project 17. To find them, you just need to be able to pick up their transmission.
This project (Figure 10-5) takes a cheap FM receiver and hacks it so that it automatically scans the FM band for the next station. If someone has started transmitting on FM, creating a station instead of the hiss of empty airwaves, you will hear their broadcast. An Arduino simulates the pressing of the tune button on the radio receiver.
Figure 10-5: FM radio frequency hopper
WHAT YOU WILL NEED
To make this project, you will need the following parts:
ITEMS
NOTES
SOURCE
Arduino Uno R3
Adafruit, Fry’s (7224833), Sparkfun
Simple low-cost FM headphone radio
Dollar Store (or equivalently named establishment in your country’s currency)
Electronics store
To connect the radio to the powered speaker
2 red LEDs
Adafruit (297)
DC power jack with flying leads, 12V cigarette lighter adapter, or 5V USB adaptor and lead
Adafruit (80), eBay
12-way right-angle header pins
eBay
We are using right-angle pins rather than straight header pins as right-angle pins make it a little easier to solder wires and component leads to this project.
Look for an FM radio that has a Tune button that moves from one station to the next and a Reset button that starts from the beginning of the FM wave band. The radio I used cost less than $2, including in-ear headphones.
The Arduino and speakers both require power. Although I have suggested using the barrel jack, you could just as easily use the USB port to power the Arduino. By now, you should be used to figuring out the most convenient way to power low-voltage devices from a 12V battery.
CONSTRUCTION
This project assumes the radio uses an SC1088 integrated circuit. This extremely low-cost chip is used in most very cheap radios, which seem to use the reference design specified in the datasheet for the chip. (Just search for “SC1088 datasheet” online; you should turn up a PDF in the first few results.) The wiring diagram is shown in Figure 10-6. It shows the Arduino being powered from the DC jack, but it could equally well be powered by the USB port.
Figure 10-6: Radio scanner wiring diagram. The numbers 15 and 16 on the SC1088 radio indicate pin numbers of the chip.
The “tune” and “reset” pins of the SC1088 IC are designed to be connected to momentary pushbuttons that short these pins to the chip’s 3V supply rail. You can see this configuration in the datasheet’s reference schematic. When pushbuttons are not shorting the input pins to the supply rail, they are pulled down to ground by variable resistances that are set inside the chip. We can emulate the functionality of the pushbutton by connecting these pins to ~3V when we want to simulate a button push, and by leaving the pin floating (not being driven high or low) when we want to simulate a button waiting to be pressed. To make the pin float, we can set the Arduino pin that is driving it to an input. When acting as an input, an I/O pin is said to be high impedance, meaning that the pin looks like an open circuit to anything that is attached to it.
To convert the 5V of the Arduino output pins to 3V, we place red LEDs between the Arduino pin and the SC1088. These drop the 5V to about 3.3V, the same level as supplied to the chip. The LEDs will also glow very slightly when activated, letting you know when the project is in operation.
STEP 1: DISASSEMBLE THE RADIO
First, take the radio apart. How to do this will depend on how your radio is put together. For mine, I just undid two screws and the whole thing came apart. Figure 10-7a shows the radio in its original state and 10-7b after removal of the case.
Figure 10-7: taking the radio apart
Take the button cell battery out because we are going to use the Arduino to supply power to the radio.
STEP 2: IDENTIFY THE CONNECTION POINTS
Now we need to identify the points where we need to attach wires and LED leads. Figure 10-8 shows the underside of the radio’s circuit board.
Start by identifying the location of the Scan and Reset switches. The pins for these will form a rectangle. The pins are connected in pairs, so both of the solder points labeled A are actually connected, as are the pair of points labeled B.
Figure 10-8: The radio PCB
The A connections are for the Reset button. If you follow the track on the PCB, you will see that one of the A pins connects to pin 16 of the SC1088 (IC pins are numbered 1 to 16 counterclockwise, with a little dot on the IC package next to pin 1).
Following the track from B, you can see that one pin connects to pin 15 of the SC1088. This is the connection that we will use to scan for the next station.
If you’re finding it hard to see where the tracks run, use your multimeter set to continuity mode to identify the pins. Press one probe to the IC pin you want to find a connection for (15 or 16) and then try the different likely connections on the switches with the other probe until the buzzer on the multimeter sounds.
Next, find the two connections needed to power the radio from the Arduino, which correspond to the battery holder connections on the PCB. The 3V batteries the radio takes have a negative central connection (C) and positive connections to the outside frame of the battery holder (D).
STEP 3: ATTACH THE HEADER STRIP
I have suggested a right-angle header strip here, because it’s easier to solder the wires to, but regular header pins work almost as well. Break off a length of 12 pins and attach them to the Arduino pins 3.3V through to A5 (Figure 10-9). One pin will sit between the two header sockets, unconnected to anything.