0% found this document useful (0 votes)
296 views

Coding For - Arduino Bluetooth Car

This Arduino code controls a Bluetooth-enabled car. It uses an Arduino and Bluetooth module to receive character commands ('1' for forward, '2' for reverse, etc.) from a smartphone app over Bluetooth to control the direction and movement of the car by turning on and off motors connected to different wheels. When a character is received, the appropriate motors are set as input or output to move the car in the corresponding direction or stop it.

Uploaded by

Fatihah Onn
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)
296 views

Coding For - Arduino Bluetooth Car

This Arduino code controls a Bluetooth-enabled car. It uses an Arduino and Bluetooth module to receive character commands ('1' for forward, '2' for reverse, etc.) from a smartphone app over Bluetooth to control the direction and movement of the car by turning on and off motors connected to different wheels. When a character is received, the appropriate motors are set as input or output to move the car in the corresponding direction or stop it.

Uploaded by

Fatihah Onn
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/ 3

https://maker.

pro/arduino/tutorial/bluetooth-basics-how-to-control-led-using-smartphone-arduino

https://www.youtube.com/watch?v=w8Qb-0et0pc&t=191s

Coding for –Arduino Bluetooth Car


char t;

void setup() {

pinMode(13,OUTPUT); //left motors forward

pinMode(12,OUTPUT); //left motors reverse

pinMode(11,OUTPUT); //right motors forward

pinMode(10,OUTPUT); //right motors reverse

Serial.begin(9600);

void loop() {

if(Serial.available()){

t = Serial.read();

Serial.println(t);

if(t == '1'){ //move forward(all motors rotate in forward direction)

digitalWrite(13,HIGH);

digitalWrite(12,LOW);

digitalWrite(11,HIGH);

digitalWrite(10,LOW);

else if(t == '2'){ //move reverse (all motors rotate in reverse direction)

digitalWrite(13,LOW);

digitalWrite(12,HIGH);

digitalWrite(11,LOW);

digitalWrite(10,HIGH);

}
else if(t == '3'){ //turn right (left side motors rotate in forward direction, right side motors doesn't
rotate)

digitalWrite(13,LOW);

digitalWrite(12,LOW);

digitalWrite(11,HIGH);

digitalWrite(10,LOW);

else if(t == '4'){ //turn left (right side motors rotate in forward direction, left side motors doesn't
rotate)

digitalWrite(13,HIGH);

digitalWrite(12,LOW);

digitalWrite(11,LOW);

digitalWrite(10,LOW);

else if(t == '5'){ //STOP (all motors stop)

digitalWrite(13,LOW);

digitalWrite(12,LOW);

digitalWrite(11,LOW);

digitalWrite(10,LOW);

delay(100);

}
*Kalau ada idea lain, boleh ja yang mana2 pn. Klau yang ni xjadi, ambil projek yang lain .

You might also like