Cov txheej txheem:

Arduino Raws Serial Servo Controller: 6 Cov Kauj Ruam
Arduino Raws Serial Servo Controller: 6 Cov Kauj Ruam

Video: Arduino Raws Serial Servo Controller: 6 Cov Kauj Ruam

Video: Arduino Raws Serial Servo Controller: 6 Cov Kauj Ruam
Video: How to add library to Arduino IDE | Error : No such file or directory 2024, Hlis ntuj nqeg
Anonim
Arduino Raws Serial Servo Controller
Arduino Raws Serial Servo Controller
Arduino Raws Serial Servo Controller
Arduino Raws Serial Servo Controller

Qhov no yog cov tswj hwm yooj yim rau ntau qhov kev pabcuam raws li Arduino. (kuv thawj qhov kev qhia ib yam nkaus:))

Feem ntau ntawm cov haujlwm hauv no tau los ntawm kev tau txais software los tham nrog arduino thiab ua cov txheej txheem rau cov ntaub ntawv kom dhau mus. Raws li rau kev kho vajtse txhua yam uas kuv siv yog ob qhov kev pabcuam (Parallax tus qauv pabcuam ntawm no.) Sparkfun Arduino ProtoShield thiab Arduino Duemilanove nrog ATMEGA328, tab sis feem ntau ntawm cov khoom no tuaj yeem hloov nrog cov khoom zoo sib xws. Kuv xav txog txoj haujlwm no ua ib feem ntawm RC system, tab sis teeb tsa kev sib txuas lus siv sijhawm ntau. Yog leej twg muaj kev txhim kho, tswv yim, lossis kab thov thov tawm tswv yim. Kho: Kuv tau sau qhov no ib pliag dhau los, nyuam qhuav tau tshaj tawm nws tsis ntev los no.

Kauj Ruam 1: Yam Koj Yuav Tsum Tau…

Yam Koj Yuav Tsum Tau…
Yam Koj Yuav Tsum Tau…
Yam Koj Yuav Tsum Tau…
Yam Koj Yuav Tsum Tau…

Qee yam koj yuav xav tau los tsim qhov no. 1. Arduino board (koj xaiv) 2. ob (lossis ib qho) servos 3. jumper xov hlau 4. Visual Studio 2008 Express - txuas (yeem) 5. Arduino IDE - txuas Thov txim Linux thiab Apple kiv cua, kuv qhov program tsuas yog ua haujlwm ntawm windows tam sim no, tab sis koj tseem tuaj yeem xa cov lus txib mus rau arduino yam tsis hloov pauv txoj cai.

Kauj ruam 2: Txuas Cov Khoom Kho Vajtse

Txuas Cov Khoom Kho Vajtse
Txuas Cov Khoom Kho Vajtse

Tsis muaj dab tsi nyuaj rau cov kauj ruam no. Kho txuas ib qho servo rau tus pin 9 thiab lwm tus los pin 10.

Kauj ruam 3: Program Arduino

Program Arduino
Program Arduino

tam sim no koj tuaj yeem xa cov duab kos mus rau arduino.

Nov yog qhov yooj yim ua txhaum txoj cai: #suav nrog Servo myservo; // tsim cov khoom siv servo los tswj lub servo Servo myservo1; int incomingByte = 0, datacount = 0, txee = 0, npaj = 0; // rau cov ntaub ntawv nkag cov ntaub ntawv char [10]; const char xyuas [8] = "ma11hew"; char hais kom ua [3]; teeb tsa tsis muaj dabtsis () {myservo.attach (9); myservo1.attach (10); Serial.begin (38400); // qhib qhov chaw nres nkoj, teev cov ntaub ntawv tus nqi Serial.println ("Nyob zoo Arduino Ntawm no!"); // ntxiv los pab txheeb xyuas qhov chaw nres nkoj txuas Qhov no tsuas yog teeb tsa chaw nres nkoj thiab servos. koj i; rau (kuv = 0; kuv <180; kuv ++) {myservo.write (kuv); ncua (15); } myservo.write (5); rau (kuv = 0; kuv <180; kuv ++) {myservo1.write (kuv); ncua (15); } myservo1.write (5); } Yooj yim sweeping txav los txheeb xyuas cov servos ua haujlwm raug. void loop () {npaj = 0; cov = 0; thaum (1 == 1) {yog (Serial.read ()! = txheeb xyuas [txee]) {tawg; } yog (txee == 6) {ncua (20); hais kom ua [0] = Serial.read (); hais kom ua [1] = Serial.read (); // yog (Serial.read () == ((hais kom [1] * 12) % 8)) // {npaj = 1; //} Serial.println ("tau txais kev cawmdim cov lus txib"); } txee ++; ncua (2); } qhov no txheeb xyuas qhov tsis raug rau txoj cai tso cai raug yog tom qab ntawd rub ob lub bytes rau qhov hais kom ua. cov lus tawm tswv yim yog tias nqe lus tso cai rau kev hloov pauv me me tab sis yuav ua rau phau ntawv cuam tshuam nyuaj. npaj tau tuaj yeem teeb tsa rau 0 yog li cov lus txib yuav tsis raug cais xws li thaum cov ntaub ntawv tsis raug. // tshawb nrhiav los ntawm cov lus txib yog (npaj == 1) {yog (hais kom ua [0] == 'T') {hais kom ua [0] = 0; Serial.print ("tswj lub qhov rooj ntawm tus pin 9 rau:"); Serial.println (daim ntawv qhia (hais kom ua [1], 32, 126, 2, 180), DEC); myservo.write (daim ntawv qhia (hais kom ua [1], 32, 126, 2, 180)); } yog (hais kom ua [0] == 'S') {hais kom ua [0] = 0; Serial.print ("tswj lub qhov rooj ntawm tus pin 10 rau:"); Serial.println (daim ntawv qhia (hais kom ua [1], 32, 126, 2, 180), DEC); myservo1.write (daim ntawv qhia (hais kom ua [1], 32, 126, 2, 180)); }}} seem ntawm cov cai yog tshawb nrhiav cov lus txib rau cov lus txib uas siv tau (T lossis S.) yog ob qho tib si nws yuav siv tus lej tom ntej thiab xa nws mus rau servo. xav paub ntau ntxiv hauv daim duab qhia chaw (hais kom ua [1], 32, 126, 2, 180) tom qab ntawd… tus lej ntawm no nthuav dav rau lwm yam uas koj xav tau (piv txwv li teeb, motors, IR, thiab lwm yam) cov cai no yuav tsum ua haujlwm zoo nrog tsis muaj kev hloov kho

Kauj ruam 4: Nruab Software

Nruab Software
Nruab Software

Kuv muaj ob txoj hauv kev los teeb tsa qhov no… nsis installer: Rub tus kheej rho tawm installer hauv qab no thiab khiav nws. Koj yuav muaj kev xaiv los teeb tsa cov peev txheej thaum lub sijhawm teeb tsa. pob installer binary pob teeb tsa cov tub ntxhais c ++ dlls yog li nws tuaj yeem ua haujlwm ntawm lub khoos phis tawj uas tsis pom kev c ++ tau teeb tsa lawm. Thaum lub installer ua tiav koj tuaj yeem khiav nws los ntawm lub desktop lossis pib ntawv qhia zaub mov. zip txoj kev (tsis tau lees paub): Rub tawm thiab khiav, nws yuav tsum ua haujlwm. tej zaum. (Zip archive muaj tib cov ntawv tais ceev tseg tsim los ntawm tus installer, tsis muaj qhov chaw. Kuv tsis muaj lub tshuab tsis muaj lub studio pom duab los sim nws yog li nws yuav tsis ua haujlwm.)

Kauj Ruam 5: Siv Qhov Kev Pabcuam Interface

Siv Txoj Haujlwm Interface
Siv Txoj Haujlwm Interface
Siv Txoj Haujlwm Interface
Siv Txoj Haujlwm Interface

Txhawm rau siv txoj haujlwm ua ntej xaiv tus nqi baud tau hais tseg hauv daim duab arduino. Cov duab kos tsis hloov pauv mus rau 38400 baud tab sis tuaj yeem hloov pauv kom haum rau koj cov kev xav tau rau yam xws li txuas xov tooj cua qeeb. nco tseg: baud tus nqi siab dua 38400 tsis tau ruaj khov, Kuv xav tias qhov no yog vim uart puv ua ntej cov ntaub ntawv tuaj yeem ua tiav. Tom ntej no, xaiv COM chaw nres nkoj los siv. qhov kev zov me nyuam tsis raug rau COM4 nco ntsoov hloov nws lossis qhov kev zov me nyuam yuav tsoo. Thaum kawg, nyem qhib. Yog tias txhua yam mus tau zoo qhov kev zov me nyuam yuav qhib qhov chaw nres nkoj xaiv ntawm xaiv tus nqi baud. Yog tias tsis yog txoj haujlwm yuav zaum sib tsoo nrog qhov tsis suav nrog. xyuas kom tseeb tias qhov chaw nres nkoj raug thiab sim dua. Siv lub thawv ntawv xa cov lus txib ncaj qha rau arduino. "Daim ntawv qhia (hais kom ua [1], 32, 126, 2, 180)" teev tag nrho 94 qhov lus txib ua tau, * chaw * los ntawm ~, nyeem tau los ntawm arduino hauv ASCII mus rau 2 txog 180 rau servo. ib qho byte tsawg dua ASCII 32 (qhov chaw) lossis siab dua 126 (~) tsis ua haujlwm rau 63 (?) Cov kab tuav tau muab eaiser interface rau cov lus txib ncaj qha. txhua kauj ruam xa cov lus txib mus rau arduino zuj zus.

Kauj Ruam 6: Tau Tsim

Tau Tsim!
Tau Tsim!
Tau Tsim!
Tau Tsim!

Xav txog tej yam txias ua nrog qhov no. Qee lub tswv yim: 1. Lub qhov rooj kaw qhov rooj rau lub tsheb. 2. 3D lub koob yees duab mount 3. underwater rover Muaj kev lom zem !!

Pom zoo: