Mundarija:

Bluetooth roboti Mio: 4 qadam
Bluetooth roboti Mio: 4 qadam

Video: Bluetooth roboti Mio: 4 qadam

Video: Bluetooth roboti Mio: 4 qadam
Video: Xiaomi Gateway 4 - Mihome автоматизации 2.0 2024, Noyabr
Anonim
Bluetooth roboti Mio
Bluetooth roboti Mio

1 -qadam: materiallar

Materiallar
Materiallar
Materiallar
Materiallar
Materiallar
Materiallar

1- Robot Mio

2- L298N kuchlanish regulyatori ikki dvigatelli haydovchi platasi

3- Arduino Nano

4- HC06 Bluetooth-seriyali modulli karta

5- (2x) 9 V batareya boshi

2 -qadam: qismlarni yig'ish

Ehtiyot qismlarni yig'ish
Ehtiyot qismlarni yig'ish
Ehtiyot qismlarni yig'ish
Ehtiyot qismlarni yig'ish
Ehtiyot qismlarni yig'ish
Ehtiyot qismlarni yig'ish
Ehtiyot qismlarni yig'ish
Ehtiyot qismlarni yig'ish

Avval dvigatel haydovchisining ulanishlaridan boshlaylik. Keling, motor haydovchisining in1, in2, in3, in4 pinlari ostidagi o'tish kabellarini lehimlaylik. (1 -rasmda) Keyin simni in1 -dan nanoning d6 -piniga, in2 -dan d10 -pinga, in3 -dan d5 -pingacha va oxir -oqibat in4 -d9 -pinli simni ulaymiz. (2 -rasmda bo'lgani kabi), keling, HC06 moduli bilan bog'lanamiz, keling, RXD pinini nano TXD piniga, TXD pinini RXD piniga, VCC va GND pinlarini har qanday 5v va GND nano pinlariga ulaymiz. (3 -rasmda) Va nihoyat, dvigatel aloqalarini o'rnataylik. Mio biz tomonga qaraganida, keling, to'g'ri dvigatel kabellarini dvigatel haydovchisining 3, 4 pimlariga, chap dvigatel kabellarini esa 1, 2 pinlarga ulaylik. nano va qora kabel GND piniga. (4 -rasmda) Keling, o'rtada o'tish simini kesib, uchini echib, nanoning GND piniga, dvigatel haydovchisining GND piniga ulaymiz. (5 -rasm, 6 -rasm) Keling, boshqa 9v akkumulyator boshining qizil kabelini 12v piniga, qora simni esa dvigatel haydovchisining pinlariga gnd piniga ulaylik. (7 -rasmdagi kabi)

3 -qadam: Nano kodlash

const int motorA1 = 5; // L298N ning IN3 Girishi

const int motorA2 = 6; // L298N ning IN1 Girishi const int motorB1 = 10; // L298N ning IN2 Girishi const int motorB2 = 9; // L298N ning IN4 Girishi

int i = 0; // Döngüler uchun atanan rastgele bir o'zgarken int j = 0; // Döngüler uchun atanan rastgele bir o'zgarken int state; // Bluetooth qurilmasidan keluvchi sinyalin o'zgarishi int vSpeed = 255; // Standart Hiz, 0-255 oralig'ida bir qiymatli bo'lishi mumkin

void setup () {// Pinlerimizni aniq belgilash pinMode (motorA1, OUTPUT); pinMode (motorA2, OUTPUT); pin rejimi (motorB1, OUTPUT); pin rejimi (motorB2, OUTPUT); // 9600 bod tezligida bir seri port ochalim Serial.begin (9600); } void loop () {// Bluetooth ulanishi koptugunda yoki kesilganida arabay turishi mumkin. // (Aktif qilish uchun pastki satrlar "//" larini olib tashlash.) // if (digitalRead (BTState) == LOW) {state = 'S'; }

// Gelen ma'lumotlarning 'holati' o'zgaruvchisiga yozilgan if (Serial.available ()> 0) {state = Serial.read (); } // Amaldan 4 tezlik darajasi. (Qiymatlar 0-255 orasida bo'lishi kerak) if (holat == '0') {vSpeed = 0;} else if (holat == '1') {vSpeed = 100;} if if (holat == '2') {vSpeed = 180;} boshqa bo'lsa (holat == '3') {vSpeed = 200;} boshqa bo'lsa (holat == '4') {vSpeed = 255;} /*** ******************** Ileri **************************/ // Gelen veri 'F' bo'lsa, avtomobil ileri gider. if (holat == 'F') {analogWrite (motorA1, vSpeed); analogWrite (motorA2, 0); analogWrite (motorB1, vSpeed); analogWrite (motorB2, 0); } /********************** Ileri Sol ************************ /// Gelen ma'lumotlar 'G' bo'lsa, avtomobil ileri sol (çapraz) gider. aks holda (holat == 'G') {analogWrite (motorA1, vSpeed); analogWrite (motorA2, 0); analogWrite (motorB1, 100); analogWrite (motorB2, 0); } /********************** Ileri Sağ ************************ /// Gelen ma'lumotlar 'I' bo'lsa, avtomobil ileri sog' (chopraz) gider. aks holda (holat == 'I') {analogWrite (motorA1, 100); analogWrite (motorA2, 0); analogWrite (motorB1, vSpeed); analogWrite (motorB2, 0); } /*********************** Geri *********************** ****/// Gelen ma'lumotlar 'B' bo'lsa, avtomobil qaytaradi. aks holda (holat == 'B') {analogWrite (motorA1, 0); analogWrite (motorA2, vSpeed); analogWrite (motorB1, 0); analogWrite (motorB2, vSpeed); } /********************** Geri Sol ************************ /// Gelen ma'lumoti 'H' bo'lsa, mashina geriga sol (chopraz) gider if if (state == 'H') {} /********************* *Geri Sağ **************************/// Gelen ma'lumotlar 'J' bo'lsa, avtomobilni qaytarib olish (chapraz) gider else if (state == ') J ') {analogWrite (motorA1, 0); analogWrite (motorA2, vSpeed); analogWrite (motorB1, 0); analogWrite (motorB2, 100); } /************************************************** *********/// Gelen ma'lumotlar 'L' bo'lsa, avtomobil sola gider. aks holda (holat == 'L') {analogWrite (motorA1, vSpeed); analogWrite (motorA2, 150); analogWrite (motorB1, 0); analogWrite (motorB2, 0); } /****************************************************** *********/// Gelen ma'lumotlar 'R' bo'lsa, avtomobil sog'a gider if if (state == 'R') {analogWrite (motorA1, 0); analogWrite (motorA2, 0); analogWrite (motorB1, vSpeed); analogWrite (motorB2, 150); } /************************STOP*********************** ******/// Gelen veri 'S' arababi durdur. aks holda (holat == '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);

4 -qadam: Mio -ga qismlarni o'rnatish

Mio -ga ehtiyot qismlarni o'rnatish
Mio -ga ehtiyot qismlarni o'rnatish
Mio -ga ehtiyot qismlarni o'rnatish
Mio -ga ehtiyot qismlarni o'rnatish
Mio -ga ehtiyot qismlarni o'rnatish
Mio -ga ehtiyot qismlarni o'rnatish

Endi biz robot mio -ni birlashtirishning oxirgi bosqichidamiz

Tavsiya: