0
Bluetooth rc car code?
I want an Arduino uno Bluetooth rc car and i can't figure out the code! i have the an arduino uno and motor module board and a Bluetooth connector i can't remember what one it's a common one though I'll check when i get home. I'm going to use two DC motors. i know how to wire everything . Please help!
3 Respuestas
+ 2
One easy posibility:
create different functions to drive the motors so that the car moves in the 4 directions.
void forward(){
digitalWrite(motor1, LOW);
digitalWrite(motor2, HIGH);
}
void left(){
digitalWrite(motor1, LOW);
digitalWrite(motor2, LOW);
}
Create a Serial event to read the incoming data from the serial buffer and call the corresponding function accordingly.
if (inChar=='w'){//if a 'w' isreceived
forward();//drive the car fwd
}
if (inChar=='a'){//when an 'a' is received
left();// drive the car left
}
this is only a basic example, the complexity of the serial protocol and the driving functions is completely up to you and the limitations of your system.
Have a look at the serialCallResponse example in the arduino IDE. It gives you an idea of serial communication between a Processing Sketch and the microcontroller.
+ 2
the arduino is programmed via c++ from the arduino IDE.
once you define a protocol of communication you can code the remote control interface with python sending serial data using pyserial library.
the arduino IDE environment is very beginner friendly. try to look at one of the many premade examples about serial communication: you may find that c++ isn't as scary as you think.
0
would this be written in c++? I'm relearning python but if c++ would be better i could finish python and go to c++ next