DRAWING CAR ARDUINO


For a project at school I had to make "digital street art". One of the requirements was using arduino. I made a small car that draws the sound levels as it moves along.
                          STEP 1: APPARATUS REQUIRED
what you will need for the basics is:
  • Arduino Uno Rev3
  • Arduino Motor Shield Rev3
  • 2x 9V battery
  • ADAFRUIT: Electret Microphone Amplifier - MAX9814 with Auto Gain Control
  • 2x Drive Motors (Drive with 3-6vdc, 200-400 mA run, 1.5A hard stall)
  • Jumper wires
  • Parallax standard Servo
  • 2x 9V battery clip with 5.5mm / 2.1mm plug
  • mountig platform
I bought a smart car kit and used the drive motors, wheels and the mounting platform from it.
what you will need for finishing off
  • chalk
  • 2x pingpong Ball
  • balsa wood 8mm
  • Foam board 5mm
a long the process I will give some codes for testing each individual part. At the End I will post the finished code that you wil need to make it work.
Picture of Making the Wheels TurnPicture of Making the Wheels TurnPicture of Making the Wheels TurnPicture of Making the Wheels Turn
In this step we are going to make the wheels turn.
what you need:
  • the arduino
  • motor shield
  • the drive motors + wheels
  • mounting plate
first we attach the drive motors to the mounting plate
than we attach the motor shield upon the arduino Uno
If that happend we are going to connect the drive motor to the motor shield
from drive motor to motor shield:
  • motor A:
    • plus (red cable) => to A+ on motor shield
    • minus (black cable) => to A- on motor shield
  • motor B:
    • plus (red cable) => to B+ on motor shield
    • minus (black cable) => to B- on motor shield
next you will need to upload the following code onto the arduino and your wheels should be turning
void setup() {
//Setup Channel A pinMode(12, OUTPUT); //Initiates Motor Channel A pin pinMode(9, OUTPUT); //Initiates Brake Channel A pin
//Setup Channel B pinMode(13, OUTPUT); //Initiates Motor Channel A pin pinMode(8, OUTPUT); //Initiates Brake Channel A pin }
void loop(){
//Motor A forward @ full speed digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A analogWrite(3, 50); //Spins the motor on Channel A at full speed
//Motor B backward @ half speed digitalWrite(13, LOW); //Establishes backward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B analogWrite(11, 50); //Spins the motor on Channel B at half speed
}

Step 2: Checking the Microphone

Picture of Checking the Microphone
Next we will check the microphone.
You will need:
  • arduino uno
  • Adafruit AGC Electret Microphone Amplifier - MAX9814
We are going to connect the microphone with the arduino
than we upload the following code, if everything is right than you should see some values in your serial plotter
const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample; void setup() { Serial.begin(9600); } void loop() { unsigned long startMillis= millis(); // Start of sample window unsigned int peakToPeak = 0; // peak-to-peak level unsigned int signalMax = 0; unsigned int signalMin = 1024; // collect data for 50 mS while (millis() - startMillis < sampleWindow) { sample = analogRead(0); if (sample < 1024) // toss out spurious readings { if (sample > signalMax) { signalMax = sample; // save just the max levels } else if (sample < signalMin) { signalMin = sample; // save just the min levels } } } peakToPeak = signalMax - signalMin; // max - min = peak-peak amplitude double volts = (peakToPeak * 5.0) / 30; // convert to volts Serial.println(volts); }

Step 3: Drawing Movement

Picture of Drawing Movement
Picture of Drawing Movement
So far we have got the wheels turning and the microphone registering the sound values.
next we are going initiate the movement of the drawing
what we need:
  • the parallax standard servo
  • motor shield
  • arduino uno
  • Adafruit AGC Electret Microphone Amplifier - MAX9814
first we attach the motor shield and the arduino.
than we need to connect the servo to the shield.
after that we connect the microphone the same way we did earlier.
than we need to upload the following code
#include
Servo myservo;
void setup() { Serial.begin(9600); myservo.attach(10);
//wielen //Setup Channel A pinMode(12, OUTPUT); //Initiates Motor Channel A pin pinMode(9, OUTPUT); //Initiates Brake Channel A pin
//Setup Channel B pinMode(13, OUTPUT); //Initiates Motor Channel A pin pinMode(8, OUTPUT); //Initiates Brake Channel A pin } void loop() {
//wielen //Motor A forward @ full speed digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A analogWrite(3, 100); //Spins the motor on Channel A at full speed
//Motor B backward @ half speed digitalWrite(13, LOW); //Establishes backward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B analogWrite(11, 100); //Spins the motor on Channel B at half speed int sample = analogRead(A0); int mapped = map(sample, 41, 100, 0, 180);
// servo map = servo // Serial.println(mapped); myservo.write(mapped); delay(90); }

Step 4: Driving While Drawing

Picture of Driving While Drawing
next we need to combine all the previous steps.
the first thing we need to do is attach the motor shield with the arduino board.
after that is done we connect the wheels and the drive motors to the shield
than we connect the microphone
and lastly we will connect the servo
just like the diagram.
than we upload the following code and if all is right we should have a moving car with a servo that reacts to sound
#include
Servo myservo;
void setup() { Serial.begin(9600); myservo.attach(10);
//wielen //Setup Channel A pinMode(12, OUTPUT); //Initiates Motor Channel A pin pinMode(9, OUTPUT); //Initiates Brake Channel A pin
//Setup Channel B pinMode(13, OUTPUT); //Initiates Motor Channel A pin pinMode(8, OUTPUT); //Initiates Brake Channel A pin } void loop() {
//wielen //Motor A forward @ full speed digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A analogWrite(3, 100); //Spins the motor on Channel A at full speed
//Motor B backward @ half speed digitalWrite(13, LOW); //Establishes backward direction of Channel B digitalWrite(8, LOW); //Disengage the Brake for Channel B analogWrite(11, 100); //Spins the motor on Channel B at half speed int sample = analogRead(A0); int mapped = map(sample, 41, 100, 0, 180);
// servo map = servo // Serial.println(mapped); myservo.write(mapped); delay(90); }

Step 5: Making the Arm With Chalk

Picture of Making the Arm With Chalk
Picture of Making the Arm With Chalk
I attached the servo motor onto the mounting plate.
than I made an arm that I mounted onto the servo motor.
you can chose how you make it. I made it out of Balsa wood because it is light and is quite strong.
I added a sketch I made before I made it out of balsa. You can adjust the hole in the middle to fit the chalk you prefer to use.
all the dimensions in the sketch are in centimeters.
Than I had some problem attaching the chalk with the arm. I tried many things but in the end the best solution were rubber ties. to be sure that the rubber ties stayed in their place I put some tape over them.

Step 6: Making a Car

Picture of Making a Car
Picture of Making a CarPicture of Making a Car
Picture of Making a Car
Like I said earlier this is a school project. My teachers want it to look nice. So I made a body to put over the construction.
I made the body out of foam board. I used foam board because I was short in time and I found it easy to work with (because my background as an architecture student)
you can see some pictures of the body.
In the picture you can see the sketch of the body. all the demension are in centimeters.
If you are wondering why I used the pingpongballs, I used it to ballance out the mounting platform. I chose for pingpong balls instead of some extra wheels because they are light can go every direction and they don't give any resistance on any surface.

Step 7: The Final Result

Picture of The Final Result
Picture of The Final ResultPicture of The Final Result
Picture of The Final Result
I haven't made a video yet, because I'm scared it will fall apart before I even have to present it.
But I do have some pictures.
If everything is right it should look like this, or even better ;)

Comments

Popular posts from this blog