Cov txheej txheem:

Arduino Tank Tsheb Zaj Lus Qhia 6-Bluetooth thiab Wifi Kub Tswj Chaw: 4 Kauj Ruam
Arduino Tank Tsheb Zaj Lus Qhia 6-Bluetooth thiab Wifi Kub Tswj Chaw: 4 Kauj Ruam

Video: Arduino Tank Tsheb Zaj Lus Qhia 6-Bluetooth thiab Wifi Kub Tswj Chaw: 4 Kauj Ruam

Video: Arduino Tank Tsheb Zaj Lus Qhia 6-Bluetooth thiab Wifi Kub Tswj Chaw: 4 Kauj Ruam
Video: 🔴Xov Xwm 3/3/2023:Polank Xa Tsheb Tank Tuaj Ntxiv Rau Yukhees-Putin Quaj Tsi Los Kua Muag 2024, Hlis ntuj nqeg
Anonim
Arduino Tank Tsheb Zaj Lus Qhia 6-Bluetooth thiab Wifi Kub Tswj Chaw
Arduino Tank Tsheb Zaj Lus Qhia 6-Bluetooth thiab Wifi Kub Tswj Chaw

Hauv zaj lus qhia no, peb kawm paub tswj hwm Robot tsheb mobile APP los ntawm WiFi thiab Bluetooth., peb tsuas yog siv lub esp8266 wifi espasion board ua pawg nthuav dav thiab tswj lub tank tsheb ntawm IR tus txais hauv cov lus qhia dhau los. Hauv zaj lus qhia no, peb yuav kawm paub siv lub xov tooj li cas txhawm rau txhawm rau kub ntawm lub rooj nthuav tawm thiab tswj lub tsheb txav ntawm lub xov tooj app. Tib lub sijhawm, koj kuj tuaj yeem tso lub bluetooth rau hauv lub rooj nthuav dav thiab tswj lub tsheb txav ntawm xov tooj bluetooth.

Cov ncauj lus kom ntxaws qhia:

Yuav nws rau Asmeskas: Amazon.com

Kauj Ruam 1: Nws Ua Haujlwm Li Cas

Nws Ua Haujlwm Li Cas
Nws Ua Haujlwm Li Cas

Muaj qhov chaw kub hu ua DoitWIFI_Config los ntawm ESP8266 pawg thawj coj hauv

lub sijhawm ua haujlwm thiab koj tuaj yeem txuas qhov chaw kub ntawm lub xov tooj wifi yam tsis muaj tus lej nkag. Thaum tig qhov hloov pauv ntawm ESP8266 pawg thawj coj mus rau "ON", cov lus los ntawm arduino thiab esp8266 tuaj yeem sib pauv los ntawm cov chaw nres nkoj txuas. Qhov kev tswj hwm tuaj yeem xa mus rau ESP8266 ntawm lub xov tooj app thiab tom qab ntawd xa mus rau arduino ntawm cov chaw nres nkoj txuas ntawm arduino thiab ESP8266 board.

Thaum tig qhov hloov pauv ntawm ESP8266 pawg thawj coj mus rau "1" thiab "2" txoj haujlwm los txiav tawm cov chaw nres nkoj txuas ntawm arduino thiab ESP8266 board. Yog tias koj tso lub bluetooth module ntawm esp8266 board thiab txuas nws ntawm xov tooj bluetooth, cov lus los ntawm arduino thiab esp8266 tuaj yeem sib pauv los ntawm cov chaw nres nkoj ntawm bluetooth module.

Nrhiav ntxiv txog ESP8266 Wifi shiled board, thov mus saib ntawm no:

Kauj Ruam 2: Kev Txhim Kho Software

Kauj Ruam 1: Nruab Arduino IDE tshiab kawg (Yog tias koj muaj Arduino IDE version tom qab 1.1.16, thov hla ntu no)

Rub tawm Arduino IDE los ntawm https://www.arduino.cc/en/Main/Software?setlang=e… ces nruab qhov software.

Kauj Ruam 2: Rub Tshooj 7 tus qauv piv txwv los ntawm https://www.kookye.com/download/car/tank_robot_les… unzip qhov rub tawm zip file tank_robot_lesson7.zip, koj yuav pom daim nplaub tshev hu ua tank_robot_lesson7.

Kauj Ruam 3: Txuas UNO R3 board rau PC nrog USB cable, Qhib Arduino IDE -> nyem cov ntaub ntawv -> nyem Qhib -> xaiv tus lej "tank_robot_lesson7.ino" hauv tank_robot_lesson7 nplaub tshev, ntsaws cov cai rau hauv arduino.

Kauj Ruam 4: Xaiv lub rooj tsav xwm sib xws thiab chaw nres nkoj rau koj txoj haujlwm, xa cov duab kos rau lub rooj tsavxwm.

Kauj Ruam 5: Rub lub APP thiab teeb nws rau hauv koj lub xov tooj: https://kookye.com/download/car/car.apk /download/car/BTcar-master.zip). Koj tuaj yeem hloov kho thiab kho tus lej raws li qhov koj xav tau.

Kauj Ruam 3: Nkag Siab Txoj Cai

Txoj haujlwm no yog siv kom tau txais kev tswj hwm los ntawm lub xov tooj app.

// WiFi /Bluetooth los ntawm kev tswj hwm

tsis muaj dab tsi do_Uart_Tick ()

{

char Uart_Date = 0;

yog (Serial.available ())

{size_t len = Serial.available ();

uint8_t sbuf [len + 1];

sbuf [len] = 0x00;

Serial.readBytes (sbuf, len);

// parseUartPackage ((char*) sbuf);

memcpy (buffUART + buffUARTIndex, sbuf, len);

// xyuas kom tseeb tias qhov chaw nres nkoj tuaj yeem nyeem tag nrho cov ntaub ntawv

buffUARTIndex += len;

preUARTTick = millis ();

yog (buffUARTIndex> = MAX_PACKETSIZE - 1)

{buffUARTIndex = MAX_PACKETSIZE - 2;

preUARTTick = preUARTTick - 200; }

}

yog (buffUARTIndex> 0 && (millis () - preUARTTick> = 100))

// APP xa tus chij txhawm rau hloov pauv qhov teeb meem kev zam

{// cov ntaub ntawv npaj buffUART [buffUARTIndex] = 0x00;

yog (buffUART [0] == 'C')

{Serial.println (buffUART);

Serial.println ("Koj tau hloov kho qhov ntsuas!");

// qhia tias qhov teeb meem kev zam qhov nrug deb tau hloov pauv sscanf (buffUART, "CMD %d, %d, %d", & distancelimit, & sidedistancelimit, & turntime);}

lwm Uart_Date = buffUART [0];

buffUARTIndex = 0;

}

hloov (Uart_Date) // cov lus qhia tswj hwm

{rooj plaub '2': Drive_Status = MANUAL_DRIVE; Drive_Num = GO_ADVANCE; Serial.println ("rau pem hauv ntej"); tawg;

rooj plaub '4': Drive_Status = MANUAL_DRIVE; Drive_Num = GO_LEFT; Serial.println ("lem sab laug"); tawg;

rooj plaub '6': Drive_Status = MANUAL_DRIVE; Drive_Num = GO_RIGHT; Serial.println ("lem sab xis"); tawg;

rooj plaub '8': Drive_Status = MANUAL_DRIVE; Drive_Num = GO_BACK; Serial.println ("rov qab mus"); so;

rooj plaub '5': Drive_Status = MANUAL_DRIVE; Drive_Num = STOP_STOP; buzz_off (); Serial.println ("nres"); so;

rooj plaub '3': Drive_Status = AUTO_DRIVE_UO; Serial.println ("zam teeb meem …"); tawg;

rooj plaub '1': Drive_Status = AUTO_DRIVE_LF; Serial.println ("kab ua raws …"); tawg;

default: tawg;

}

}

Kauj Ruam 4: Kev Kho Vajtse

Kev Kho Vajtse
Kev Kho Vajtse
Kev Kho Vajtse
Kev Kho Vajtse
Kev Kho Vajtse
Kev Kho Vajtse

Kauj Ruam 1: Txhim Kho ESP8266 Kev nthuav tawm ntawm UNO R3 board.

Kauj Ruam 2: Yog tias koj xav tswj lub tsheb los ntawm bluetooth, thov teeb tsa bluetooth module ntawm ESP8266 raws li hauv qab no thiab muab hloov mus rau "1, 2" txoj haujlwm. Yog tias koj xav tswj lub tsheb los ntawm wifi, thov khaws esp8266 pawg thawj coj tsis muaj bluetooth module thiab tig qhov hloov ntawm esp8266 rau "ntawm" txoj haujlwm..

Nco tseg: Bluetooth module thiab Arduino board sib tham nrog txhua lwm yam los ntawm UART serial chaw nres nkoj. Thov tshem tawm bluetooth module ua ntej rub tawm daim duab hauv Arduino pawg thawj coj, lossis cov duab kos yuav raug xa mus yam tsis tau ua tiav.

Kauj Ruam 3: Muab ob lub roj teeb 12865 tso rau hauv lub thawv roj teeb thiab tig lub npov rau "ON". (Yog tias koj tau ua tiav cov theem saum toj no ntawm zaj lus qhia ib, thov hla cov kauj ruam no)

Kauj Ruam 4: Qhib xov tooj app thiab wifi, nrhiav qhov kub hu ua "DoitWIFI_Config" thiab txuas nws.

Kauj ruam 5: Qhib app >> xaiv hom WiFi >> tom qab ntawd koj tuaj yeem tswj lub tsheb neeg hlau hla wifi

Kauj Ruam 6: Yog tias koj xav tswj lub tsheb neeg hlau hla Bluetooth, thov qhib bluetooth ntawm koj lub xov tooj Android uas koj tau teeb tsa APP thiab luam theej duab bluetooth (txawv bluetooth module yuav luam theej duab lub npe bluetooth sib txawv), Nyem txuas thiab nkag lo lus zais "1234" lossis "0000" yog tias tsis muaj kev hloov pauv (Koj tuaj yeem hloov pauv wifi lossis bluetooth teeb tsa hauv xov tooj Android kom hloov los tswj lub tsheb hla wifi lossis bluetooth):

Kauj ruam 7: Qhib app >> xaiv hom bluetooth >> tom qab ntawd koj tuaj yeem tswj hwm lub tsheb neeg hlau los ntawm bluetooth:

Muaj peb hom kev ua haujlwm: kev tswj phau ntawv, kev zam kev zam thiab taug qab. Cov neeg siv tuaj yeem hloov pauv dawb ntawm peb hom kev ua haujlwm. 1) Hauv hom kev tswj, koj tuaj yeem nyem cov nyees khawm (^) (V) () los tswj lub tsheb Robot kom txav mus rau tom ntej thiab rov qab, tig sab xis thiab sab laug. Lub caij no, APP tuaj yeem soj ntsuam lub tsheb lub sijhawm tiag tiag.

2) Nyem "taug qab" khawm ntawm App txhawm rau hloov pauv tam sim no mus rau hom kev taug qab. Lub Tsheb Neeg Hlau yuav txav mus tom ntej raws txoj kab dub hauv keeb kwm dawb. Lub caij no, APP tuaj yeem soj ntsuam lub tsheb lub sijhawm tiag tiag. Nias "||" khawm kom tsis txhob txav mus thiab nyem rau lwm lub pob kom hloov Robot tsheb ua haujlwm hom. Txhawm rau kawm paub ntau ntxiv txog hom no, thov tshuaj xyuas peb tshooj 4.

3) Nyem rau "Obstacle" khawm txhawm rau hloov hom tam sim no rau hom kev zam. Lub Tsheb Neeg Hlau tuaj yeem tsav mus rau tom ntej tsis tu ncua thiab nres thiab tawm mus ib zaug thaum muaj teeb meem hauv nws txoj kev. Nias "||" khawm kom tsis txhob txav mus thiab tom qab ntawd nyem rau lwm lub pob kom hloov Robot tsheb ua haujlwm hom. Txhawm rau kawm paub ntau ntxiv txog hom no, thov tshuaj xyuas peb tshooj 5.

Pom zoo: