RC Boat With HC-06 Bluetooth Module
by Azmi Deliaslan in Circuits > Arduino
667 Views, 0 Favorites, 0 Comments
RC Boat With HC-06 Bluetooth Module
I will show you how can you make a RC BOAT but it just for 25 meters distance! i use bluetooth module but if you want to use Nfr it would be healty for long distance.
PARTS
Here is a list of parts that i used to make this project:
- DC motor and propeller
- L298 motor driver
- Arduino UNO
- HC-06 Bluteth module
- 18v battery and voltage regulatör
- Servo Motor
- Jumper Wires
SCHEMA
ı use a battery which output is 18v so ı use regulator for decrease the voltage !
CODE
The code has explanations of code functions. You will easly understand it. If you have a problem , you can contact me.
#include
// include servo libraryconst int in1 = 10; // dc motor in pin const int in2 = 11; const int enA = 6; //motor speed
Servo rudder; //create servo name
void setup() { pinMode(in1, OUTPUT); //all motor pins are output pinMode(in2, OUTPUT); pinMode(enA, OUTPUT); rudder.attach(9); //servo attachment Serial.begin(9600); //For Serial communication }
void loop() { if(Serial.available()>0){ //if we communicate with hc 05 char way = Serial.read(); //get the input //Serial.write(way); //if you wanna learn which word you have got //Go forward if(way=='w'){ analogWrite(enA, 255); //set left the speed(0 to 255) digitalWrite(in1, LOW); digitalWrite(in2,HIGH); rudder.write(90); } //Go Backward else if(way=='s'){ analogWrite(enA, 255); digitalWrite(in1, HIGH); digitalWrite(in2, LOW); rudder.write(90); }
//Turn RIGHT else if(way=='a'){ analogWrite(enA, 255); digitalWrite(in1, LOW); digitalWrite(in2,HIGH); rudder.write(45); }
//Turn LEFT else if(way=='d'){ analogWrite(enA, 255); digitalWrite(in1, LOW); digitalWrite(in2,HIGH); rudder.write(135); }
//Stop the ship else if(way=='n'){ digitalWrite(in1, HIGH); //if we make HIGH every pin it will stop digitalWrite(in2, HIGH); //or you can do => analogWrite(enA,0); rudder.write(180); }
//PIR PIR else if(way=='k'){ digitalWrite(in1, HIGH); //if we make HIGH every pin it will stop digitalWrite(in2, HIGH); //or you can do => analogWrite(enA,0); int pos; for(pos = 60; pos <= 120 ; pos+=10){ rudder.write(pos); delay(15); } for(pos = 120; pos >= 60 ; pos-=10){ rudder.write(pos); delay(15); } }
//BACKWARD TURN LEFT else if(way=='l'){ digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enA, 155); rudder.write(45); }
//BACKWARD TURN RIGHT else if(way=='m'){ digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enA, 155); rudder.write(135);7 } else{ digitalWrite(in1, HIGH); //if we make HIGH every pin it will stop digitalWrite(in2, HIGH); //or you can do => analogWrite(enA,0); } } }