Monthly Archives: October 2013

A New Remote Control for My RC Car

2013-10-12 16.45.48

For a long time I’ve been thinking about incorporating the accelerometer or/and the gyroscope into my projects but don’t really know what I want to build. This past week, I realised that I could make another remote control for my RC car using an accelerometer, and immediately started building it. The accelerometer module I used is a MMA8451 breakout. The one shown in the picture is not from sparkfun but has a very similar schematic. I used the example code from sparkfun to read acceleration values from the accelerometer and the corresponding command for the RC Car is sent out using the XBee. I added a 5×7 LED matrix to shown the command currently being sent out in the form of arrows and, if the car is not moving, a circle. You can use the remote in either the landscape mode, which is similar to playing mario cart using the wiimote, or the portrait mode, where every instruction is based on the position of the remote relative to the horizontal plane. I will make a video to demonstrate the full functionality of this remote soon.

About the XBee

The XBee breakout shown in the picture is from Parallax. You can get it straight from Parallax, or from Digikey. The way to connect this breakout board is shown in the schematic below.

Untitled

The D1 is a 3.3V zener diode with part number 1N4728 (1W) or 1N5226 (1/2W). The MCP1700 is a low dropout voltage regulator and you can find the 3.3V version here. DIN, VCC, and VSS are the only three connections you need to make on the XBee breakout.

Updates on Both the Piano and the Tetris Game

2013-10-12 16.46.46

On my Arduino piano, the LM386 amplifier circuit has been replaced by a MAX98306 class D amplifier board from Adafruit. This board gives me more control over the gain, and makes the maximum volume much higher given the same supply voltage (3.7V lipo). There was originally quite a lot of noise coming out of the speaker, and for weeks I simply couldn’t figure out where that noise is from. Last week I tried to comment out sections of code and add delays at different places, and see if it has any effect on the noise. Through this investigation, I realised that the noise on the pin of the ATmega328 that is connected to the input of the amplifier is heavily affected by other operations on all the other pins. I soon realised that there is a way to hide these noise from the amplifier instead of removing them. Instead of tying the other input to the amplifier to ground, I connected it to another pin on the ATmega328 that is set to LOW. In this way, the same noise cancels out each other on the two pins, and the output would become very clean. 

2013-10-12 16.54.24

As I said in a previous post, I added a LED bar graph to the Tetris game to reflect the progress in the game. Currently the setting in the code is that one additional segment on the bar graph turns on for every 5 lines cleared in the game. The setting on the speed at which the piece drops makes it really difficult to go through a total of 50 lines. Also, in order to make the bar graph more lively, I used a timer interrupt to flash the next segment at 1Hz, before it turns solid after the 5 lines are cleared.

Another big change to the layout on the breadboard is that I replaced the 9V battery with two 3.7V 300mAh lipo batteries. This change is not that necessary, but I just don’t want to have any  components hanging off the edge of the breadboard.