0% found this document useful (0 votes)
58 views2 pages

Arduino Voice Controlled Robot Car

This document describes an Arduino voice controlled robot car. It includes code to control two motors and a servo motor to move the car forward, backward, right, left, and stop based on voice commands detected by the serial monitor. The car uses an AF_DCMotor library to control two motors to drive the wheels and a Servo library to control the direction of the servo motor attached to the front of the car. Voice commands are compared to strings to call the appropriate motor control functions to drive the car.

Uploaded by

Zasni Zaxx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views2 pages

Arduino Voice Controlled Robot Car

This document describes an Arduino voice controlled robot car. It includes code to control two motors and a servo motor to move the car forward, backward, right, left, and stop based on voice commands detected by the serial monitor. The car uses an AF_DCMotor library to control two motors to drive the wheels and a Servo library to control the direction of the servo motor attached to the front of the car. Voice commands are compared to strings to call the appropriate motor control functions to drive the car.

Uploaded by

Zasni Zaxx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Arduino Voice Controlled Robot

Car
}

voice="";
}
}

void forward_car()
{
motor1.run(FORWARD);
motor1.setSpeed(700);
//viral science motor2.run(FORWARD);
//voice controlled car motor2.setSpeed(700);
delay(2000);
#include <AFMotor.h> motor1.run(RELEASE);
#include <Servo.h> motor2.run(RELEASE);
String voice; }

AF_DCMotor motor1 (1, MOTOR12_1KHZ); void back_car()


AF_DCMotor motor2 (2, MOTOR12_1KHZ); {
Servo myServo; motor1.run(BACKWARD);
motor1.setSpeed(700);
void setup() motor2.run(BACKWARD);
{ motor2.setSpeed(700);
Serial.begin(9600); delay(2000);
myServo.attach(10); motor1.run(RELEASE);
myServo.write(90); motor2.run(RELEASE);
}
}
void right_car()
void loop() {
{ myServo.write(0);
while (Serial.available()){ delay(1000);
delay(10); myServo.write(90);
char c = Serial.read(); delay(1000);
if (c == '#') {break;} motor1.run(FORWARD);
voice += c; motor1.setSpeed(190);
} motor2.run(BACKWARD);
if (voice.length() > 0){ motor2.setSpeed(190);
if(voice == "*go ahead"){ delay(1000);
forward_car(); motor1.run(RELEASE);
} motor2.run(RELEASE);
else if(voice == "*go back"){ }
back_car();
} void left_car()
else if(voice == "*right") { {
right_car(); myServo.write(180);
} delay(1000);
else if(voice == "*left") { myServo.write(90);
left_car(); delay(1000);
} motor1.run(BACKWARD);
else if(voice == "*stop") { motor1.setSpeed(190);
stop_car(); motor2.run(FORWARD);
motor2.setSpeed(190);
delay(1000);
motor1.run(RELEASE);
motor2.run(RELEASE);
}

void stop_car ()
{
motor1.run(RELEASE);
motor2.run(RELEASE);
}

You might also like