Cov txheej txheem:

Tsis Siv Neeg Lub Teeb Pom Kev Taug Qab: 5 Cov Kauj Ruam
Tsis Siv Neeg Lub Teeb Pom Kev Taug Qab: 5 Cov Kauj Ruam

Video: Tsis Siv Neeg Lub Teeb Pom Kev Taug Qab: 5 Cov Kauj Ruam

Video: Tsis Siv Neeg Lub Teeb Pom Kev Taug Qab: 5 Cov Kauj Ruam
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Kaum ib hlis
Anonim
Tsis Siv Neeg Lub Teeb Pom Kev Taug Qab
Tsis Siv Neeg Lub Teeb Pom Kev Taug Qab

Hauv zaj lus qhia no, peb yuav siv lub tshuab ua haujlwm servo, lub tshuab photoresistor thiab rub tawm tus neeg tawm tsam kom sib sau ua ke kom pom lub teeb pom kev zoo.

Kauj Ruam 1: Cheeb Tsam:

- Arduino Uno board * 1

- USB cable * 1

- Servo tsav * 1

- photoresistor * 1

- Resistor (10k) * 1

- Daim phiaj * 1

- Jumper xov hlau

Kauj Ruam 2: Txoj Cai

Lub tshuab servo thiab lub tshuab ntsuas hluav taws xob luam theej duab thiab nrhiav lub teeb ci hauv 180 degree thiab sau qhov chaw ntawm lub teeb ci. Tom qab ua tiav kev tshuaj xyuas, lub tshuab servo thiab lub photoresistor nres ntawm qhov kev taw qhia ntawm lub teeb ci.

Kauj Ruam 3: Cov txheej txheem:

Cov txheej txheem
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, yog tias koj siv lub teeb nyem kom ci lub photoresistor, koj yuav pom lub cav servo thiab lub tshuab photoresistor tig, thiab thaum kawg nres ntawm qhov kev taw qhia ntawm lub teeb ci.

Kauj ruam 4: Schematic Daim duab

Schematic Daim duab
Schematic Daim duab

Kauj ruam 5: Code

Code
Code
Code
Code
Code
Code

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

* npe:

Tau Taug Qab Qhov Teeb Pom Kev

* muaj nuj nqi

: yog tias koj siv lub teeb nyem kom ci rau lub photoresistor, * koj yuav pom

servo motor thiab photoresistor tig, * thiab thaum kawg

nres ntawm qhov kev taw qhia ntawm lub teeb ci.

***********************************************************************

/Email: [email protected]

// Lub Vev Xaib: www.primerobotics.in

#suav nrog

const int photocellPin = A0;

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

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

int outputValue = 0;

int kaum = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180};

int maxVal = 0;

int maxPos = 0;

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

void teeb tsa ()

{

Serial.begin (9600);

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

}

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

void lub voj ()

{

rau (int i = 0;

kuv <19; kuv ++)

{

myservo.write (lub kaum ); // sau lub kaum rau servo

Cov txiaj ntsig

= analogRead (photocellPin); // nyeem tus nqi ntawm A0

Serial.println (outputValue); // luam nws

yog (outputValue> maxVal) // yog tias tus nqi tam sim no ntawm A0 ntau dua li yav dhau los

{

maxVal = outputValue; // sau tus nqi

maxPos

= kuv; //

}

ncua (200);

}

myservo.write (kaum sab xis [maxPos]); // sau lub kaum sab xis rau servo uas A0 muaj tus nqi ntau tshaj

thaum (1);

}

Pom zoo: