drawing car arduino

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); }

Source: www.bing.com


Related Posts To drawing car arduino


drawing car arduino Rating: 4.5 Posted by: Brot Trune

Search Here

Popular Posts

Total Pageviews

Recent Posts