123lYT
Published

Arduino Car

A simple arduino based 2 wheel car with l289n and hc-05

IntermediateFull instructions provided638
Arduino Car

Things used in this project

Hardware components

HC-05 Bluetooth Module
HC-05 Bluetooth Module
hc-06 will do aswell
×1
Arduino UNO
Arduino UNO
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1

Software apps and online services

Snappy Ubuntu Core
Snappy Ubuntu Core
preferred for more advanced users
Windows 10
Microsoft Windows 10
you can do it with this aswell

Story

Read more

Schematics

Schematic

Once you have connected everything try to do the usual smoke test.
NOTE: when uploading unplug the hc-06/05 rxd/txd pins from the arduino to avoid the 500 out of sync error

Code

Code

C/C++
Shove it into your arduino ide and send it off.
/*
Code by NGX aka Clover aka 123lYT
Atom Development @ Google Play

Feel free to add whatever you like to this code and present it to anyone
*/

#include <SoftwareSerial.h>
 
SoftwareSerial blueToothSerial(0, 1);
 
int IN1 = 9;   //IN1 pin
int IN2 = 10;  //IN2 pin
int IN3 = 11;  //IN3 pin
int IN4 = 12;  //IN4 pin
int ENA = 6;   //ENA pin
int ENB = 5;   //ENB pin
char t;
 
/*BT module HC-05 connect by the rule:
   TX --> RX
   RX --> TX
   because T(ransmit)X - sends information
           R(ecieve)X - recieves information
 */
 
void setup() {
  pinMode(IN1, OUTPUT); //IN1 pin
  pinMode(IN2, OUTPUT); //IN2 pin
  pinMode(IN3, OUTPUT); //IN3 pin
  pinMode(IN4, OUTPUT); //IN4 pin  
  pinMode(ENA, OUTPUT); //ENA pin
  pinMode(ENB, OUTPUT); //ENB pin
  Serial.begin (9600);
}
 
void loop() {
 while (Serial.available() > 0) { //writes out the recieved information from the app
    t = Serial.read();
  }
//Serial.print ("C: ");
  Serial.println (t);
   //Serial.print ("D: ");
       switch (t) {   
    case 'F': //command Forward
      digitalWrite(ENA, HIGH);
      digitalWrite(ENB, HIGH);
      digitalWrite(IN4, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN1, LOW);  
    break;
    case 'B': //command Backward
      digitalWrite(ENA, HIGH);
      digitalWrite(ENB, HIGH);
      digitalWrite(IN4, LOW);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN1, HIGH); 
    break;
    case 'L': //command Left
      digitalWrite(ENA, HIGH);
      digitalWrite(ENB, LOW);
      digitalWrite(IN4, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN1, LOW);
    break;
    case 'R': //command Right
      digitalWrite(ENA, LOW);
      digitalWrite(ENB, HIGH);
      digitalWrite(IN4, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN2, LOW);
      digitalWrite(IN1, LOW); 
    break;
    case 'S': //Stop
      digitalWrite(ENA, LOW);
      digitalWrite(ENB, LOW);
      digitalWrite(IN4, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN2, LOW);
      digitalWrite(IN1, LOW); 
    break;
    }
}

Credits

123lYT

123lYT

5 projects • 3 followers

Comments