Bluetooth Robot Mio

by 1nv1nc1ble in Circuits > Arduino

1266 Views, 4 Favorites, 0 Comments

Bluetooth Robot Mio

IMG_20200809_173214[1].jpg

Materials

IMG_20200809_154443.jpg
IMG_20200809_154451.jpg
IMG_20200809_154517.jpg
IMG_20200809_154507.jpg
IMG_20200809_154524.jpg

1- Robot Mio

2- L298N Voltage Regulator Dual Motor Driver Board

3- Arduino Nano

4- HC06 Bluetooth-Serial Module Board

5- (2x) 9 V Battery Head

Assembling Parts

IMG_20200809_165146[1].jpg
IMG_20200809_165204[1].jpg
IMG_20200809_165306[1].jpg
IMG_20200809_165350[1].jpg
IMG_20200809_165803[1].jpg
IMG_20200809_165911[1].jpg
IMG_20200809_170808[1].jpg

Let's start with the motor driver connections first Let's solder the jumper cables under the in1, in2, in3, in4 pins of the motor driver. (as pic1)Then let's wire the cable in in1 to nano's d6 pin, in2 to d10 pin, in3 to d5 pin, and finally the cable in in4 to d9 pin. (as in picture 2)Now, let's make the connections of our HC06 module, let's wire RXD pin to TXD pin of nano, TXD pin to RXD pin, VCC and GND pins to any 5v and GND pins of nano. (as pic3)And finally, let's make the motor connections. When Mio is facing us, let's connect the right motor cables to the out 3,4 pins of the motor driver and the left motor cables to the out1,2 pins.Let's connect the red cable of the 9v battery cap to the VIN pin of the nano and the black cable to the GND pin. (as pic4)And let's cut a jumper wire in the middle, strip the end and connect it to the GND pin of the nano, to the GND pin of the motor driver. (as pic5,6)Let's connect the red cable of another 9v battery head to the 12v pin and the black cable to the gnd pin on the motor driver power pins. (as in picture7 )

Coding Nano

const int motorA1 = 5; // L298N'in IN3 Girişi

const int motorA2 = 6; // L298N'in IN1 Girişi const int motorB1 = 10; // L298N'in IN2 Girişi const int motorB2 = 9; // L298N'in IN4 Girişi

int i=0; //Döngüler için atanan rastgele bir değişken int j=0; //Döngüler için atanan rastgele bir değişken int state; //Bluetooth cihazından gelecek sinyalin değişkeni int vSpeed=255; // Standart Hız, 0-255 arası bir değer alabilir

void setup() { // Pinlerimizi belirleyelim pinMode(motorA1, OUTPUT); pinMode(motorA2, OUTPUT); pinMode(motorB1, OUTPUT); pinMode(motorB2, OUTPUT); // 9600 baud hızında bir seri port açalım Serial.begin(9600); } void loop() { //Bluetooth bağlantısı koptuğunda veya kesildiğinde arabayı durdur. //(Aktif etmek için alt satırın "//" larını kaldırın.) // if(digitalRead(BTState)==LOW) { state='S'; }

//Gelen veriyi 'state' değişkenine kaydet if(Serial.available() > 0){ state = Serial.read(); } // Uygulamadan ayarlanabilen 4 hız seviyesi.(Değerler 0-255 arasında olmalı) if (state == '0'){ vSpeed=0;} else if (state == '1'){ vSpeed=100;} else if (state == '2'){ vSpeed=180;} else if (state == '3'){ vSpeed=200;} else if (state == '4'){ vSpeed=255;} /***********************İleri****************************/ //Gelen veri 'F' ise araba ileri gider. if (state == 'F') { analogWrite(motorA1, vSpeed); analogWrite(motorA2, 0); analogWrite(motorB1, vSpeed); analogWrite(motorB2, 0); } /**********************İleri Sol************************/ //Gelen veri 'G' ise araba ileri sol(çapraz) gider. else if (state == 'G') { analogWrite(motorA1,vSpeed ); analogWrite(motorA2, 0); analogWrite(motorB1, 100); analogWrite(motorB2, 0); } /**********************İleri Sağ************************/ //Gelen veri 'I' ise araba ileri sağ(çapraz) gider. else if (state == 'I') { analogWrite(motorA1, 100); analogWrite(motorA2, 0); analogWrite(motorB1, vSpeed); analogWrite(motorB2, 0); } /***********************Geri****************************/ //Gelen veri 'B' ise araba geri gider. else if (state == 'B') { analogWrite(motorA1, 0); analogWrite(motorA2, vSpeed); analogWrite(motorB1, 0); analogWrite(motorB2, vSpeed); } /**********************Geri Sol************************/ //Gelen veri 'H' ise araba geri sol(çapraz) gider else if (state == 'H') { } /**********************Geri Sağ************************/ //Gelen veri 'J' ise araba geri sağ(çapraz) gider else if (state == 'J') { analogWrite(motorA1, 0); analogWrite(motorA2, vSpeed); analogWrite(motorB1, 0); analogWrite(motorB2, 100); } /***************************Sol*****************************/ //Gelen veri 'L' ise araba sola gider. else if (state == 'L') { analogWrite(motorA1, vSpeed); analogWrite(motorA2, 150); analogWrite(motorB1, 0); analogWrite(motorB2, 0); } /***************************Sağ*****************************/ //Gelen veri 'R' ise araba sağa gider else if (state == 'R') { analogWrite(motorA1, 0); analogWrite(motorA2, 0); analogWrite(motorB1, vSpeed); analogWrite(motorB2, 150); } /************************Stop*****************************/ //Gelen veri 'S' ise arabayı durdur. else if (state == 'S'){ analogWrite(motorA1, 0); analogWrite(motorA2, 0); analogWrite(motorB1, 0); analogWrite(motorB2, 0); } } analogWrite(motorA1, 0); analogWrite(motorA2, 100); analogWrite(motorB1, 0); analogWrite(motorB2, vSpeed);

Installing Parts on Mio

IMG_20200809_172652[1].jpg
IMG_20200809_172901[1].jpg
IMG_20200809_172907[1].jpg

Now we are at the final stage to merge robot mio