Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
akssil-ga
Published © Apache-2.0

Controlled car using Bluetooth

A small car based on a Bluetooth model in Arduino, a perfect project to get started on Arduino and robotics.

IntermediateProtip466
Controlled car using Bluetooth

Things used in this project

Hardware components

9V battery (generic)
9V battery (generic)
×1
Slide Switch
Slide Switch
×1
9V Battery Clip
9V Battery Clip
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
DC Motor, 12 V
DC Motor, 12 V
×2
Maker Essentials - Micro-motors & Grippy Wheels
Pimoroni Maker Essentials - Micro-motors & Grippy Wheels
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Battery Holder, AA x 2
Battery Holder, AA x 2
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Tape, Foam
Tape, Foam

Story

Read more

Schematics

The circuit diagram from fretzing

Code

The code of this project is shown below

Arduino
char inputByte='0';
int speedpin=2;
int dir1=3;
int dir2=4;
int mspeed=255;
int speedpin2=5;
int dir11=6;
int dir22=7;
 
void setup() {
 Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(speedpin,OUTPUT);
pinMode(dir1,OUTPUT);
pinMode(dir2,OUTPUT);

}
int distance = 0;
void loop() {
while(Serial.available()>0){
 inputByte = Serial.read();
  Serial.println(inputByte);
  if (inputByte=='1'){
  
   digitalWrite(dir1,HIGH);
  digitalWrite(dir2,LOW);
  analogWrite(speedpin,255);
   digitalWrite(dir11,HIGH);
  digitalWrite(dir22,LOW);
  analogWrite(speedpin2,255);
  }
  else if (inputByte=='2'){
   digitalWrite(dir1,0);
  digitalWrite(dir2,0);
  analogWrite(speedpin,0);
   digitalWrite(dir11,0);
  digitalWrite(dir22,0);
  analogWrite(speedpin,0);
 
  } 
    else if (inputByte=='3'){
  
 digitalWrite(dir1,0);
  digitalWrite(dir2,1);
  analogWrite(speedpin,255);
   digitalWrite(dir11,0);
  digitalWrite(dir22,1);
  analogWrite(speedpin,255);
 
  }
   else if (inputByte=='4'){
  
   digitalWrite(dir1,0);
  digitalWrite(dir2,1);
  analogWrite(speedpin,255);
   digitalWrite(dir11,0);
  digitalWrite(dir22,1);
  analogWrite(speedpin2,100);
  }
    else if (inputByte=='5'){
  
    digitalWrite(dir1,0);
  digitalWrite(dir2,1);
  analogWrite(speedpin,100);
   digitalWrite(dir11,0);
  digitalWrite(dir22,1);
  analogWrite(speedpin2,255);
  }
 




  } 



}

Credits

akssil-ga
5 projects • 5 followers
wameedh scientific club
Contact

Comments

Please log in or sign up to comment.