Orodha ya maudhui:

Bluetooth Robot Mio: Hatua 4
Bluetooth Robot Mio: Hatua 4

Video: Bluetooth Robot Mio: Hatua 4

Video: Bluetooth Robot Mio: Hatua 4
Video: Айфон 4 - ЛУЧШИЙ АЙФОН ВСЕХ ВРЕМЁН 2024, Novemba
Anonim
Bluetooth Robot Mio
Bluetooth Robot Mio

Hatua ya 1: Vifaa

Vifaa
Vifaa
Vifaa
Vifaa
Vifaa
Vifaa

1- Mio ya Robot

2- L298N Mdhibiti wa Voltage Dual Motor Dereva Board

3- Arduino Nano

4- HC06 Bodi ya Moduli ya Bluetooth-Serial

5- (2x) 9 V Kichwa cha Betri

Hatua ya 2: Kukusanya Sehemu

Kukusanya Sehemu
Kukusanya Sehemu
Kukusanya Sehemu
Kukusanya Sehemu
Kukusanya Sehemu
Kukusanya Sehemu
Kukusanya Sehemu
Kukusanya Sehemu

Wacha tuanze na unganisho la dereva wa gari kwanza Wacha tuunganishe nyaya za kuruka chini ya in1, in2, in3, in4 pini za dereva wa gari. (kama pic1) Basi wacha tuunganishe kebo kwa 1 kwa pini ya dano ya nano, in2 hadi d10 pini, in3 hadi d5 pini, na mwishowe kebo ndani ya pini ya in4 hadi d9. (kama ilivyo kwenye picha 2) Sasa, wacha tufanye unganisho la moduli yetu ya HC06, wacha tuunganishe pini ya RXD kwa pini ya TXD ya nano, pini ya TXD kwa pini ya RXD, VCC na pini za GND kwa pini yoyote ya 5v na GND ya nano. (kama pic3) Na mwishowe, wacha tufanye unganisho la gari. Mio inapotukabili, wacha tuunganishe nyaya za kulia za gari kwenye pini 3, 4 za dereva wa gari na nyaya za kushoto kwa pini za 1, 2. Wacha tuunganishe kebo nyekundu ya kofia ya betri ya 9v kwenye pini ya VIN ya nano na kebo nyeusi kwenye pini ya GND. (kama pic4) Na wacha tukate waya ya kuruka katikati, vua mwisho na uiunganishe na pini ya GND ya nano, kwa pini ya GND ya dereva wa gari. (kama pic5, 6) Wacha tuunganishe kebo nyekundu ya kichwa kingine cha betri 9v kwenye pini ya 12v na kebo nyeusi kwenye pini ya gnd kwenye pini za umeme za dereva. (kama kwenye picha7)

Hatua ya 3: Kuandika Nano

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

motor 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

kuanzisha batili () {// 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); } kitanzi batili () {// 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ı) ikiwa (state == '0') {vSpeed = 0;} mwingine ikiwa (state == '1') {vSpeed = 100;} mwingine ikiwa (state == '2') {vSpeed = 180;} mwingine ikiwa (state == '3') {vSpeed = 200;} mwingine ikiwa (state == '4') {vSpeed = 255;} / *** ******************** İleri **************************** / // Gelen veri 'F' ise araba ileri gider. ikiwa (state == 'F') {analogWrite (motorA1, vSpeed); AnalogWrite (motorA2, 0); AnalogWrite (motorB1, vSpeed); AnalogWrite (motorB2, 0); } / ********************** İleri Sol ************************ / // Gelen veri 'G' ise araba ileri sol (çapraz) mpokeaji. vinginevyo ikiwa (state == 'G') {analogWrite (motorA1, vSpeed); AnalogWrite (motorA2, 0); AnalogWrite (motorB1, 100); AnalogWrite (motorB2, 0); } / ********************** İleri Sağ ************************ / // Gelen veri 'I' ise araba ileri sağ (çapraz) mpokeaji. vinginevyo ikiwa (state == 'I') {analogWrite (motorA1, 100); AnalogWrite (motorA2, 0); AnalogWrite (motorB1, vSpeed); AnalogWrite (motorB2, 0); } / *********************** Geri ************************ **** / // Gelen veri 'B' ise araba geri gider. vinginevyo ikiwa (state == 'B') {analogWrite (motorA1, 0); AnalogWrite (motorA2, vSpeed); AnalogWrite (motorB1, 0); AnalogWrite (motorB2, vSpeed); } / ********************** Geri Sol ************************ / // Gelen veri 'H' ise araba geri sol (çapraz) mpokeaji mwingine ikiwa (state == 'H') {} / ********************* * Geri Sağ ************************ / // Gelen veri 'J' ise araba geri sağ (çapraz) mpokeaji mwingine ikiwa (state == ' J ') {analogWrite (motorA1, 0); AnalogWrite (motorA2, vSpeed); AnalogWrite (motorB1, 0); AnalogWrite (motorB2, 100); } / *************************** Sol Sol ******************** ********* / // Gelen veri 'L' ise araba sola gider. vinginevyo ikiwa (state == 'L') {analogWrite (motorA1, vSpeed); AnalogWrite (motorA2, 150); AnalogWrite (motorB1, 0); AnalogWrite (motorB2, 0); } / *************************** Sağ ******************** ********* / // Gelen veri 'R' ise araba sağa mpasua mwingine ikiwa (state == 'R') {analogWrite (motorA1, 0); AnalogWrite (motorA2, 0); AnalogWrite (motorB1, vSpeed); AnalogWrite (motorB2, 150); } / ************************ Acha *********************** ****** / // Gelen veri 'S' ise arabayı durdur. vinginevyo ikiwa (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);

Hatua ya 4: Kuweka Sehemu kwenye Mio

Kuweka Sehemu kwenye Mio
Kuweka Sehemu kwenye Mio
Kuweka Sehemu kwenye Mio
Kuweka Sehemu kwenye Mio
Kuweka Sehemu kwenye Mio
Kuweka Sehemu kwenye Mio

Sasa tuko katika hatua ya mwisho ya kuunganisha mio ya roboti

Ilipendekeza: