Devices & Components
Arduino Uno Rev3
Dual H-Bridge motor drivers L298
HC-05 Bluetooth Module
Software & Tools
Snappy Ubuntu Core
Windows 10
Project description
Code
Code
c_cpp
Shove it into your arduino ide and send it off.
1/* 2Code by NGX aka Clover aka 123lYT 3Atom Development @ Google Play 4 5Feel free to add whatever you like to this code and present it to anyone 6*/ 7 8#include <SoftwareSerial.h> 9 10SoftwareSerial blueToothSerial(0, 1); 11 12int IN1 = 9; //IN1 pin 13int IN2 = 10; //IN2 pin 14int IN3 = 11; //IN3 pin 15int IN4 = 12; //IN4 pin 16int ENA = 6; //ENA pin 17int ENB = 5; //ENB pin 18char t; 19 20/*BT module HC-05 connect by the rule: 21 TX --> RX 22 RX --> TX 23 because T(ransmit)X - sends information 24 R(ecieve)X - recieves information 25 */ 26 27void setup() { 28 pinMode(IN1, OUTPUT); //IN1 pin 29 pinMode(IN2, OUTPUT); //IN2 pin 30 pinMode(IN3, OUTPUT); //IN3 pin 31 pinMode(IN4, OUTPUT); //IN4 pin 32 pinMode(ENA, OUTPUT); //ENA pin 33 pinMode(ENB, OUTPUT); //ENB pin 34 Serial.begin (9600); 35} 36 37void loop() { 38 while (Serial.available() > 0) { //writes out the recieved information from the app 39 t = Serial.read(); 40 } 41//Serial.print ("C: "); 42 Serial.println (t); 43 //Serial.print ("D: "); 44 switch (t) { 45 case 'F': //command Forward 46 digitalWrite(ENA, HIGH); 47 digitalWrite(ENB, HIGH); 48 digitalWrite(IN4, HIGH); 49 digitalWrite(IN3, LOW); 50 digitalWrite(IN2, HIGH); 51 digitalWrite(IN1, LOW); 52 break; 53 case 'B': //command Backward 54 digitalWrite(ENA, HIGH); 55 digitalWrite(ENB, HIGH); 56 digitalWrite(IN4, LOW); 57 digitalWrite(IN3, HIGH); 58 digitalWrite(IN2, LOW); 59 digitalWrite(IN1, HIGH); 60 break; 61 case 'L': //command Left 62 digitalWrite(ENA, HIGH); 63 digitalWrite(ENB, LOW); 64 digitalWrite(IN4, LOW); 65 digitalWrite(IN3, LOW); 66 digitalWrite(IN2, HIGH); 67 digitalWrite(IN1, LOW); 68 break; 69 case 'R': //command Right 70 digitalWrite(ENA, LOW); 71 digitalWrite(ENB, HIGH); 72 digitalWrite(IN4, HIGH); 73 digitalWrite(IN3, LOW); 74 digitalWrite(IN2, LOW); 75 digitalWrite(IN1, LOW); 76 break; 77 case 'S': //Stop 78 digitalWrite(ENA, LOW); 79 digitalWrite(ENB, LOW); 80 digitalWrite(IN4, LOW); 81 digitalWrite(IN3, LOW); 82 digitalWrite(IN2, LOW); 83 digitalWrite(IN1, LOW); 84 break; 85 } 86}
Downloadable files
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
Schematic

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
Schematic

Comments
Only logged in users can leave comments