Make a Car with hc-05 and arduino uno #include <AFMotor.h> //initial motors pin AF_DCMotor motor1 ( 1 , MOTOR12_1KHZ ) ; AF_DCMotor motor2 ( 2 , MOTOR12_1KHZ ) ; AF_DCMotor motor3 ( 3 , MOTOR34_1KHZ ) ; AF_DCMotor motor4 ( 4 , MOTOR34_1KHZ ) ; char command; void setup () { Serial . begin ( 9600 ) ; //Set the baud rate to your Bluetooth module. } void loop (){ if ( Serial . available () > 0 ){ command = Serial . read () ; Stop () ; //initialize with motors stoped //Change pin mode only if new command is different from previous. //Serial.println(command); switch ( command ){ case 'F': forward () ; break ; case 'B': back () ; break ; case 'L': left () ; ...
Comments
Post a Comment