Cov txheej txheem:

SERVO MOTOR NROG ARDUINO UNO R3: 5 Cov Kauj Ruam
SERVO MOTOR NROG ARDUINO UNO R3: 5 Cov Kauj Ruam

Video: SERVO MOTOR NROG ARDUINO UNO R3: 5 Cov Kauj Ruam

Video: SERVO MOTOR NROG ARDUINO UNO R3: 5 Cov Kauj Ruam
Video: How To Make A DIY Arduino Line Follower Car At Home 2024, Lub Xya hli ntuj
Anonim
SERVO MOTOR NROG ARDUINO UNO R3
SERVO MOTOR NROG ARDUINO UNO R3

Servo yog ib hom ntawm lub cev muaj zog uas tsuas tuaj yeem tig 180 degrees. Nws tau tswj hwm los ntawm kev xa hluav taws xob los ntawm koj lub Arduino Uno board. Cov mem tes no qhia rau servo txoj haujlwm nws yuav tsum txav mus rau qhov twg.

Kauj Ruam 1: Cov Cheeb Tsam Yuav Tsum Tau

- Arduino Uno board * 1

- USB cable * 1

- Kev pabcuam * 1

- Daim phiaj * 1

- Jumper xov hlau

Kauj Ruam 2: Txoj Cai

Servo muaj lub plhaub, lub rooj tsav xwm hauv tsev, tsis siv lub cev muaj zog, iav thiab nrhiav chaw. Nws txoj haujlwm ua haujlwm yog raws li hauv qab no: Arduino Uno board xa PWM teeb liab rau servo lub cev muaj zog, thiab tom qab ntawd lub teeb liab no tau ua tiav los ntawm IC ntawm lub rooj tsav xwm hauv vaj huam sib luag los xam cov kev taw qhia kom tig lub cav, thiab tom qab ntawd lub zog tsav no tau xa mus rau caj npab los ntawm kev txo qis iav. Nyob rau tib lub sijhawm, txoj haujlwm ntsuas rov qab teeb liab qhov chaw los txiav txim seb qhov chaw tau mus txog lossis tsis.

Kauj Ruam 3: Daim duab qhia chaw

Schematic Daim duab
Schematic Daim duab

Kauj ruam 4: Cov txheej txheem

Cov txheej txheem
Cov txheej txheem
Cov txheej txheem
Cov txheej txheem

Kauj ruam 1:

Tsim lub voj voog.

Kauj ruam 2:

Rub tawm cov cai los ntawm

Kauj ruam 3:

Tshaj tawm cov duab kos rau Arduino Uno board

Nyem rau Upload icon txhawm rau upload cov cai rau pawg tswj hwm.

Yog tias "Ua tiav uploading" tshwm rau hauv qab ntawm lub qhov rais, nws txhais tau hais tias daim duab tau ua tiav tiav.

Tam sim no, koj tuaj yeem pom servo motor tig 90 degrees (tig ib zaug txhua 15 degrees). Thiab tom qab ntawd tig hauv qhov kev coj rov qab.

Kauj ruam 5: Code

/***********************************************

* Lub npe: Servo

* ua haujlwm: koj tuaj yeem pom servo motor tig 90 degrees (tig ib zaug txhua 15 degrees).

* Thiab tom qab ntawd tig mus rau qhov rov qab.

************************************************/

// Email: [email protected]

// Lub Vev Xaib: www.primerobotics.in

#suav nrog

/************************************************/

Servo myservo; // tsim cov khoom siv servo los tswj lub servo

/************************************************/

void teeb tsa ()

{

myservo.attach (9); // txuas cov servo ntawm tus pin 9 rau cov khoom siv servo

myservo.write (0); // rov qab mus rau 0 degrees

ncua (1000); // tos ib pliag

}

/*************************************************/

void lub voj ()

{

myservo.write (15); // mus rau 15 degrees

ncua (1000); // tos ib pliag

myservo.write (30); // mus rau 30 degrees

ncua (1000); // tos thib ob. 33

myservo.write (45); // mus rau 45 degrees

ncua (1000); // tos thib ob. 33

myservo.write (60); // mus rau 60 degrees

ncua (1000); // tos thib ob. 33

myservo.write (75); // mus rau 75 degrees

ncua (1000); // tos thib ob. 33

myservo.write (90); // mus rau 90 degrees

ncua (1000); // tos ib pliag

myservo.write (75); // rov qab mus rau 75 degrees

ncua (1000); // tos thib ob. 33

myservo.write (60); // rov qab mus rau 60 degrees

ncua (1000); // tos thib ob. 33

myservo.write (45); // rov qab mus rau 45 degrees

ncua (1000); // tos thib ob. 33

myservo.write (30); // rov qab mus rau 30 degrees

ncua (1000); // tos thib ob. 33

myservo.write (15); // rov qab mus rau 15 degrees

ncua (1000); // tos ib pliag

myservo.write (0); // rov qab mus rau 0 degrees

ncua (1000); // tos ib pliag

}

/**************************************************/

Pom zoo: