## Remote control

We use the IRLib library to decode the signal from the infrared detector. This library supports many of the common TV remote controls. Use the included example sketch IRecvDump to see if your remote is supported. On the serial monitor you should see something like “Decoded NEC(1): Value:FD808F (32 bits)”. If you have a supported remote control, skip to the “Movements” section further down this page.

In our case, we had to add support for our SilverLit remote control.

## SilverLit RC

The SilverLit Remote Control vehicle protocol is meant to the SilverLit RC set that was sold through Costco and included a dump truck, flatbed, bulldozer or crane. We reuse this remote control to direct the movements of the Droid robot.

The protocol was undocumented, and I reverse engineered it. Turns out that the remote control first transmits a header burst of 38 kHz infrared light. The bits are then transferred as short or longer period with no IR light (space) followed by short burst of IR light (mark).

encoding
13 bits data bits
1 bit stop bit

The bits are encoded as shown below.

bit value encoding
“0” 0,400 msec space, followed by 0.722 msec mark
“1” 1.037 msec space, followed by 0.722 msec mark

The data bits are shown in the table below.

bit(s) meaning
[12:11] vehicle identifier (00=dumptruck, 01=flatbed, 10=bulldozer, 11=crane)
[10:9] no special meaning. 11 when bit[7] is 0, otherwise 00
[8] 0 for backward
[7] 0 for forward
[6] 1 for right
[5] 1 for left
[4] 1 for down
[3] 1 for up
[2] 1 for light on
[1:0] checksum (see below)

The CRC is calculated as follows

checksum = bit[11:12] ^ bit[10] ^ bit[9:8] ^ bit[7:6] ^bit[5:4] ^ bit[3:2]

We forked Chris Young’s IRLib, to add support for SilverLit remote vehicle/car protocol. My version of the library is available on GitHub.

## Movements

2BD: describe how instructions trigger movements

## Audio spectrum

This page describes how the peak values of the frequency bands are retrieved.

The spectrum analyzer chip (MSGEQ7) measures the peak voltage in 7 frequency bands. These voltages are multiplexed on one output pin. To read each value, we use the RESET and STROBE* pins.

1. A RESET pulse followed by a wait (≥72 μs) resets the multiplexer.
2. On the first falling edge of the strobe signal, the 63 Hz output propagates to OUT. After ≥36 μs, this analog value can be read by the host.
3. Each additional strobe falling edge advances the multiplexer one frequency band (63 > 160 > 400 > 1,000 › 2,500 > 6,250 > 16,000 Hz) and this will repeat indefinitely.

The multiplexer read rate is also the output decay time control. Each read decays that the value of that frequency band by approximately 10%. [datasheet]

The timing is shown below, and includes some corrections compared to the datasheet [Maxfield].

With a load of 33pF//1MΩ, the settle time of the output is 36 μs. The output impedance of the MSGEQ7 is 700 Ω. This is well under the Arduino recommended 10 kΩ for the A/D sample-and-hold capacitor to charge up.

## Build environment

The code has been compiled using the Arduino 1.6.5 tool chain. The code should compile user the Arduino IDE. Another option is the derived Atmel Studio that supports an In Circuit Emulator (ICE). However, the IDE flavor should be irrelevant to the compilation.

## Configure the tool chain

• Turning on the compiler warnings
• e.g. Visual Studio > Tools > Visual Micro > Compiler Warning
• Enable C++11 support (to allow enum classes).
• e.g. add -Wall -std=c++11 to compiler.cpp.flags in hardware/arduino/avr/platform.txt
• Install the libraries
• Chris Young’s IRLib., or my fork when you use the SilverLit remote (see page ???). Note that you can’t have the original IRLib library installed because it will cause a conflict.
• Either place them in the libraries folder to your Arduino tool chain, or in the libraries folder in your sketchbook path. Note that the Arduino tool chain doesn’t understand #include "dir1/dir2/header.h"
• e.g. Visual Studio (Tools » Visual Micro » Reload tool chains)
• Select the correct board type,
• Clear the build, and rebuild

## Code

The following pages describe the implementation.

## Hardware

This project uses two input sources, a microphone and an IR detector. It also has two outputs, a LED matrix and a robot (Droid). The microphone picks up the sound of music, and the system displays the audio spectrum and makes the droid dance to the beat of music. It can also operate in a mode where it receives signals from a remote control to demonstrate the droid’s movements.

## Schematics

We ended up putting the MSGEQ7 and its glue on piece of proto board. The critical parts are in the oscillation circuit connected the CLIN input. The odd duck is the 200kΩ resistor that is not an E12-series value. You can also make an equivalent value by 220 kΩ and 2.2 MΩ in parallel, or put two 100kΩ in series. Now that we’re on the subject: all capacitors should be ceramic types.

## Bill of Materials

The price comes down to under $40 based on single quantity, excluding shipping and taxes. However, note that some items, such as the PCB, have minimum order quantities. Name Description Suggested mfr and part# Paid PCB1 Arduino METRO 328, or Arduino Uno R3 Adafruit 2488$17.50
PCB2 Bicolor LED Square Pixel Matrix with I2C breakout Adafruit 902 $15.95 PCB3 Electret microphone w/ auto gain control Adafruit 1713$7.95
U1 Seven Band Graphic Equalizer Display Filter Mixed Signal MSGEQ7 $U2 MOSFET P-CH 12V/4.3A, SOT-23 Infineon IRLML6401TRPBF$0.53
U3 Linear voltage regulator, 6V/1.5A, TO220-3 STMicroelectronics L7806CV $0.69 U4 IR detector$
D1, D2, D3, D4 Schottky diode, 30V/200mA, SOD523 Onsemi RB520S30T5G $R1, R2 Resistor, 22 kOhm, 1/8 W, 0805 Yageo RC0805FR-0722KL$0.10
R3 Resistor, 200 kOhm, 1/8 W, 0805 $R4 Resistor, 200 Ohm, 1/8 W, 0805$
C1, C2, C3 Capacitor, 0.1 µF, multi-layer ceramic, 6.3 V, 0805 KEMET C0805C104M3RACTU $0.10 C4 Capacitor, 33 pF, multi-layer ceramic, 6.3 V, 0805$
C5 Capacitor, 0.33 uF, multi-layer ceramic, 16V, 0805 $C6 Capacitor, 0.1 uF, multi-layer ceramic, 16V, 0805$
J1 Headphone jack stereo connector, 3.5mm, kinked pin Kycon STX-3120-5B $0.74 J2 Power connector jack, 2X5.5mm, kinked pin CUI PJ-202A$0.71
Connectors JST, 1.25mm pitch (GH) Kycon $M1 Digital Micro Servo, 4.8-6V, 0.09sec/60°, 22.4×12.5x23mm, 9g Turnigy TG9d$4.12
M2, M3, M4 Ultra-Micro Digital Servo 4.8-6V. 0.08sec, 16x8x18mm, 2g H-King HKM-282A \$4.50

Make sure the MSGEQ7 is authentic. It should draw about $$0.8\,\rm{mA}$$; pin 6 should have a reference voltage of $$2.5\,\rm{V}$$ and have an indentation near pin 1.

## Materials

The components listed below are available from components warehouses like Mouser and DigiKey, and hobby stores like Adafruit and Sparkfun.

### Microphone

We use the same microphone breakout, as we did in the Pitch Detector project. This breakout has an amplifier that automatically controls the gain up to a 2 Vpp output signal. Other microphones will work for as long as the output signal is strong enough. Alternatively, you can connect directly to a music source using a 3.5 mm phone connector. This outputs about 0.9 Vpp. In all cases, remember to decouple the DC component using the 0.1 μF capacitor.

### Spectrum Analyzer

This MSGEQ7 spectrum analyzer chip requires some analog components as listed below.

• 22 kΩ (red-red-orange)
• 0.1 μF (104, blue multi-layer ceramic capacitor)
• 0.1 μF (104, blue multi-layer ceramic capacitor)
• 33 pF (33, brown ceramic capacitor), correct value is important!
• 200 kΩ by placing 220 kΩ (red-red-yellow) and 2.2 MΩ in parallel (red-red-green)

Not all MSGEQ7 chips are made equally. We found it helpful to solder these components and a chip socket on a little breakout. This makes it easy to try different chips.

The MSGEQ7 is very sensitive to noise on the power rail. Add a 47 μF across the power line seems to help.

### Infrared Remote and Detector

We used a SilverLit infrared remote to send control signals to the Arduino, but any remote that is supported by the Arduino IRLib library should work. The infrared (IR) detector demodulates the received IR signal and outputs a pulse stream. For the detector we used a TSOP38238, but again there are many other flavors that may work.

### Arduino

We use the commonly available Arduino UNO R3 Given that you are reading this article, you are probably already familiar with this open-source microcontroller prototyping platform.

Remember to connect 3.3 Volt to the AREF input. The Analog-to-Digital converter uses this as a reference.

### Bi-color 8×8 LED matrix

For the display we choose an I2C 8×8 Bicolor LED matrix. This matrix connects using the two wire I2C interface, an inter integrated circuit protocol like the SPI that I described in my article Math Talk.

### Droid

We sacrificed an Android Mini Collectible Figure from the Google store in Mountain View. After cutting the legs, arms and popping off the head, it assault intensified by drilling out its eyes. We followed the instructions for the pink figure in this instructable. To move the ams and head, we used 3 small ultra-micro servos. These come with an 1.25 mm pitch Molex Picoblade connector, that requires a small extension cable. The body itself is moved with a larger micro servos that connects using the more traditional 2.5 mm pitch JST-XH connector. For the eyes we used two LEDs in series and a current limiting resistor.

These ultra-micro servos have a maximum voltage of 4.7 Volt and the combination of servos can draw up to 500 mA. We supply this 4.7 Volt rail using a separate lap power supply. Signaling diodes bring the 5 V output from the Arduino down to about 4.3 Volt.