I am currently building an Rc car and for some reason the wheels aren't moving according to the code i have written. The right wheel moves anti clockwise whilst the left wheel moves clocwise and regardless of what code i input it doesn't stop or change. My project is due date tomorrow so some help would be appreaciated
Please put your code in its own window as seen in other posts. This can be done by placing [code] and [/code] around the code or use the </> icon. This makes it easier for others to read.
Without the code AND circuit we have no idea what you are doing. Hand drawn and photographed is ok.
Weedpharma
Here is the code:
#include <Servo.h>
Servo left;//Define left servo
Servo right;//Define right servo
byte val;
void setup()
{
Serial.begin(115200);//Change the baud rate value depending on the default baud rate of your bluetooth module, for Bluesmirf-115200 and for JY-MCU-9600
left.attach(11, 800, 2200); //left servo on digital pin 9 of arduino
right.attach(12, 800, 2200); //right servo on digital pin 10 of arduino
}
void loop()
{
int a=0;
if(Serial.available())
{
val=Serial.read();
Serial.println(int(val));
if(int(val)==49)//Move front
{
right.write(180);//Rotates servo clockwise
left.write(0);//Rotates servo anticlockwise
}
if(int(val)==50)//Move back
{
right.write(0);
left.write(180);
}
if(int(val)==53)//Stop
{
right.write(90);//Stops the servos
left.write(90);//Stops the servos
}
if(int(val)==51)//left
{
right.write(180);
left.write(90);
}
if(int(val)==52)//right
{
right.write(90);
left.write(0);
}}
}
Below is the wiring:

Check to see if those AA batteries are able to supply the required current.
If possible..... try to get some arduino code that applies a pwm control signal to one motor. The pwm frequency needs to be 50 Hz and high time pulse width of 1500 microsecond will put the servo into the mid position.
Try a code like this....
.....click here.......
I already did, and it still doesn't work. It just turns continuously.
A useful device to have is one of these: BestDealUK Servo Tester CCPM Consistency Master Checker 3ch 4.8-6v for sale online | eBay