My goal is to make you comfortable with building, running and modifying your very own ghost box. Then you can decide just how it should work and why!

So let’s tear into it a few lines at a time.

The Code Title

The first couple of lines of real code are the Code Title area.

Here is where the author is telling you who wrote this app and where they can be find. They also tell you the way the intend the code to work and any other info.

Remember: comments are in red. They are not acutal code, just author notes.

/**
@file fmrx_demo.ino
@author www.elechouse.com
@brief example of FMRX_MODULE
For this demo, input character '1' from serial monitor to seek channel down, '2' to seek down
'3' to volume up, '4' to volume down.'&xxxx' (x is for a number) to manually set receive FM frequency
@section HISTORY
V1.0 initial version
Copyright (c) 2012 www.elechouse.com All right reserved.
*/

Alright, so that’s telling us that elechouse.com made the fmrx demo and how it works.

Including Libraries

Next we really start to build the program. Here is where the author sets up what library the Arduino will be using.A library is a simple set of additional code that’s grouped together. Libraries make it easier to create complex programs.

/** include library */
#include

Not too bad. There’s only one library called for in this basic program.

Declaring Functions

Now let’s look at the first section of the main program. Here the Author starts out by declaring a function called setup:

Communication is setup communicate to the computer and the Arduino:

Serial.begin(9600);

Command is issued to signal to the computer the program is active:

Serial.print("FM-RX Demo By Elechosue\r\n");

Radio module communication is started:

/** I2C initial */
i2c_init();

Radio is not turned on “Initialized”:

fmrx_power();
fmrx_read_reg(fmrx_reg_r);

Announce the Radio is running:

Serial.print("FMRX Module Power up.\r\n");

Set up the operations for the radio (volume, signal strength and band):

case '4':
Serial.println("Wait...");
if(vol > 0){
vol--;
}
fmrx_set_volume(vol);
Serial.print("Volume-:");
Serial.println(vol);
break;
/** check data for setting new channel. Input data must start with '&' and followed by 4 numbers, the first 3 is the integer part
(Unit: MHz), the last one is the decimal part.And the channel must between 76MHz and 108Mhz.(eg: &0756 for 75.6MHz, and &0666 is out of range)
*/

You’ll Need the Following Supplies

Arduino and USB cable

Serial FM radio module with Amplifier

male to female single pin jumper wires

More About your Supplies

1 – Arduino and USB cable
For this Project we will be using the Arduino Uno R3.
This is a processor board with built in interface for USB. Easily available from numerous sources including our own Ghost Box Hacks.

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.

There are several types of Arduino boards, however we will only be using the UNO. Most all the Adruino versions will work for these projects, but it may be easier for beginners to follow the Arduino Uno R3.

1 – Serial FM radio module with Amplifier

This module communicates with the Arduino through I2C interface. All commands are sent through I2C interface.