Hey guys I got so many request for this code so this is for you guys
First empower Bluetooth and build up association with BT module (ex. HC-06, secret phrase 1234). Utilize the "Help and Info" catch in the event that you can't see how it is functioning.
Accelerometer work is a work in progress, use with alert!
In the event that you have issue with this application on your Android gadget, you can likewise utilize this one.
/***************************BLUETOOTH CONTROLLED CAR CODE**************************/ //Declare the arduino pins int lm1 = 10; int lm2 = 9; int rm1 = 8; int rm2 = 7; int horn = 11; int fl = 3; int bl = 2; void setup() { //initlize the mode of the pins pinMode(lm1,OUTPUT); pinMode(lm2,OUTPUT); pinMode(rm1,OUTPUT); pinMode(rm2,OUTPUT); pinMode(horn,OUTPUT); pinMode(fl,OUTPUT); pinMode(bl,OUTPUT); //set the serial communication rate Serial.begin(9600); } void loop() { //check whether arduino is reciving signal or not while(Serial.available() == 0); char val = Serial.read() ;//reads the signal Serial.print(val); /*********For Forward motion*********/ if (val == 'F') { Serial.println("FORWARD"); digitalWrite(lm1,HIGH); digitalWrite(rm1,HIGH); digitalWrite(lm2,LOW); digitalWrite(rm2,LOW); } /*********For Backward Motion*********/ else if(val == 'B') { Serial.println("BACK"); digitalWrite(lm2,HIGH); digitalWrite(rm2,HIGH); digitalWrite(lm1,LOW); digitalWrite(rm1,LOW); } /*********Right*********/ else if(val == 'R') { Serial.println("RIGHT"); digitalWrite(lm1,HIGH); digitalWrite(rm2,HIGH); digitalWrite(lm2,LOW); digitalWrite(rm1,LOW); } /*********Left*********/ else if(val == 'L') { Serial.println("LEFT"); digitalWrite(lm2,HIGH); digitalWrite(rm1,HIGH); digitalWrite(lm1,LOW); digitalWrite(rm2,LOW); } /*********Horn*********/ else if(val == 'V') { digitalWrite(horn,HIGH); } else if(val == 'v') { digitalWrite(horn,LOW); } /*********Front Lights*********/ else if(val == 'W') { digitalWrite(fl,HIGH); } else if(val == 'w') { digitalWrite(fl,LOW); } /*********Back Lights*********/ else if(val == 'U') { digitalWrite(bl,HIGH); } else if(val == 'u') { digitalWrite(bl,LOW); } /*********STOP*********/ else { Serial.println("Invalid!!!"); digitalWrite(lm1,LOW); digitalWrite(rm1,LOW); digitalWrite(lm2,LOW); digitalWrite(rm2,LOW); } }
First empower Bluetooth and build up association with BT module (ex. HC-06, secret phrase 1234). Utilize the "Help and Info" catch in the event that you can't see how it is functioning.
Accelerometer work is a work in progress, use with alert!
In the event that you have issue with this application on your Android gadget, you can likewise utilize this one.