Things used in this project

Hardware components:
09670 01
SparkFun Dual H-Bridge motor drivers L298
Because the arduino can't driver the motor directly, we need the L298 to drive the motor.
×1
MATRIX HC-06
×1
Software apps and online services:
Bluetooth SPP
Hand tools and fabrication machines:
A4kb1xynkid5ebvjyil7
Digilent Screwdriver

Schematics

How to link this.
64b9a8cb39dbb6fd566fa5ac0c24ab18962b37e2 tptzbibdri

Code

To set up the hc-06C/C++
#define AT 2
#define LED 13
void setup()
{
pinMode(LED,OUTPUT);
pinMode(AT,OUTPUT);
digitalWrite(AT,HIGH);
Serial.begin(9600);
delay(100);
Serial.println("AT");
delay(100);
Serial.println("AT+NAME=smart car");
delay(100);
Serial.println("AT+ROLE=S");
delay(100);
Serial.println("AT+PIN=1234");
delay(100);
Serial.println("AT+BAUD=9600");
delay(100);
Serial.println("AT+RMAAD");
void loop()
{
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
The code that uses the L298 controling the car.C/C++
#define IN1 4
#define IN2 5
#define IN3 6
#define IN4 7
void forward();
void back();
void turnLeft();
void turnRight();
void turnbackLeft();
void turnbackRight();
void turnLeftOrigin();
void turnRightOrigin();
void _stop();
void setup()
{ pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
Serial.begin(9600);
}
int i;
void loop()
{ if(Serial.available())
{ i= Serial.read();
switch(i)
{ case'1':{ turnLeft();break;}
case'2':{ forward();break;}
case'3':{turnRight();break;}
case'4':{turnLeftOrigin();break;}
case'5':{_stop();break;}
case'6':{turnRightOrigin();break;}
case'7':{turnbackLeft();break;}
case'8':{back();break;}
case'9':{turnbackRight();break;}
}
}
}
void forward()
{ digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
}
void back()
{ digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
}
void turnLeft()
{ digitalWrite(IN1,LOW);
digitalWrite(IN2,LOW);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
}
void turnbackLeft()
{ digitalWrite(IN1,LOW);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
}
void turnRight()
{ digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,LOW);
}
void turnbackRight()
{ digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,LOW);
digitalWrite(IN4,LOW);
}
void turnLeftOrigin()
{ digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
}
void turnRightOrigin()
{ digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);
}
void _stop()
{ digitalWrite(IN1,LOW);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN4,LOW);
}

Credits

Ce4ad4e6a6e4a3e6354bdd088cbaf8c6
f591604497
0 projects • 0 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login