Introduction: Accelerometer-Controlled Pololu Zumo Car
This is a Biomedical Instrumentation Lab Project we did at Vanderbilt University. The idea was to create a system for a quadriplegic patient to control their wheel chair. The wheel chair was represented by a Pololu Zumo car. We accomplished steering by measuring head tilt with an accelerometer.
Although this device was never intended to make it to the "real world", we learned some valuable and awesome concepts from Arduino and accelerometers.
Materials:
Pololu Zumo Car
Arduino Uno board
MMA 7361 Accelerometer
Breadboard
3 LEDs
3 1000-ohm resistors
Soldering Iron
Wires
1 6-pin Arduino Stackable header; female
2 8-pin Arduino Stackable headers; female
Step 1: Learning About the MMA7361 Accelerometer
This step is designed to let you get to know the accelerometer and determine the values needed for head tilt
Initial Set-up:
1. Solder wires into each of the 9 pin holes on the accelerometer. We recommend wires at least 2 feet long- so your car has room to move in the future (ours are short because we inherited the accelerometer from another project in lab)
2. Connect each of the corresponding wires onto the Arduino Uno board:
ST--> this pin is not needed- do not hook up
GSEL--> Digital Pin 4
0GD--> Digital Pin 5
SLP--> Digital Pin 3
X out --> Analog Pin 0
Y out --> Analog Pin 1
Z out --> Analog Pin 2
GND--> GND (Ground)
VCC--> 3.3V (DO NOT put this on 5V, it may blow out the accelerometer!)
3. Download and install the MMA7361 Library onto your Arduino program:
https://github.com/jeroendoggen/Arduino-MMA7361-li...
The library includes some sample codes that can help you understand how the accelerometer works.
4. Write Code: This code will print the accelerometer out put to the serial window (strike Ctrl + Shift+ M to pull up). You can then play with your accelerometer to determine what output values you need
A note about calibrations: The accelerometer has a built in calibration function and will calibrate for about 5-10 sec after launching the serial window. It needs to be held flat against a flat surface (see picture) in order to properly calibrate.
You can copy and paste the code in the attached document.
Attachments
Step 2: Wiring Your Accelerometer to a LED Bed
To demonstrate the proof of concept, we wired up a LED bed before starting on the Zumo car. We set up the circuit shown in the pictures using the 3 resistors and the LEDs on the breadboard.
When setting up the LEDs, take note of which digital pins (8, 9 or 10- these are the pins used in the code for the next step) each one is hooked up to, because each LED represents a direction (Forward, Left, Right).
Step 3: LED Bed Code
Using the MMA7361 Library and the data you collected from step one, you can construct a code such that a certain LED lights up depending on the direction you tilt.
You will need to declare Variables x, y, and z, as well as 3 boolean values (see picture). After that, we created a series of if and for loops, an example is typed below:
//forward
//Forward is a boolean variable
if (Forward) {
digitalWrite(8, HIGH);
} else {
digitalWrite(8, LOW);
}
You can also copy and paste the entire code from the attached document.
When this code is uploaded, only one LED should light up depending on which direction you are tilting.
Attachments
Step 4: Zumo Set Up
In order to operate the accelerometer and the Zumo car through a single Arduino, you need to solder the stackable headers onto the Zumo (see pic). The Arduino fits onto the Zumo, but it is upside down. The stackable headers need to be soldered onto the corresponding pins on the Zumo, this way everything connects. Make sure you solder everything in the right place! All pins on the Arduino correspond directly to the adjacent pins on the accelerometer.
Once this is accomplished you can wire the accelerometer onto the Zumo.
Step 5: Driving the Zumo Car
The pictures above show the accelerometer wired to the Zumo in two ways that are essentially the same. When we got the accelerometer, it already had the short wires soldered to it- so we used the breadboard to link up longer wires to make driving the car a little easier. If you soldered long wires to you accelerometer, this is not needed.
Next, you need to download the Zumo library onto your Arduino Program:
https://github.com/pololu/zumo-shield/tree/master/...
You can learn how to use this library from the provided examples that download with the code. This is a good way to see how the motor running code works and can help you understand our code.
After that it is a simple matter of modifying your LED code for the motors (see screenshot). You can also copy and paste the code from the attached document.
Once that is uploaded, unhook the USB cord, turn on the Zumo car and tilt you accelerometer. Off your car zooms!