Cov txheej txheem:

Suab Sensor & Servo: Reactive Motion: 4 Kauj Ruam
Suab Sensor & Servo: Reactive Motion: 4 Kauj Ruam
Anonim
Suab Sensor & Servo: Reactive Motion
Suab Sensor & Servo: Reactive Motion
Suab Sensor & Servo: Reactive Motion
Suab Sensor & Servo: Reactive Motion
Suab Sensor & Servo: Reactive Motion
Suab Sensor & Servo: Reactive Motion

Ua ntej koj yuav tsum sib sau cov ntaub ntawv cuam tshuam los tso rau hauv Circuit Court no ua ke.

Khoom siv:

1 Arduino

1 Ultrasonic Sensor HC-SR04

1 Servo cov

1 Cov qhob cij

19 Volt Roj Teeb

19 Volt Roj Teeb Adapter

3 Cov Hluav Taws Xob Dub (Hauv av/Tsis Zoo)

3 Red Jumper Wires (Voltage/Positive)

2 Xim Jumper Hluav Taws Xob (Tawm Tawm/Tawm Tawm)

Kauj Ruam 1: Nkag Siab Cov Cheeb Tsam

Nkag siab Cov Cheeb Tsam
Nkag siab Cov Cheeb Tsam
Nkag siab Cov Cheeb Tsam
Nkag siab Cov Cheeb Tsam
Nkag siab Cov Cheeb Tsam
Nkag siab Cov Cheeb Tsam

Nws yog ib qho tseem ceeb ua ntej muab tso ua ke lub cev sib tw kom nkag siab txhua qhov kev tiv thaiv:

Lub khob cij muaj ob txheej ntawm txoj kab hluav taws xob ntawm ob sab, uas muaj qhov qhib rau qhov tsis zoo (dub/xiav) thiab qhov zoo (liab) cov tswv yim. Lawv tau txuas nrog hauv kab ntsug. Cov davhlau ya nyob twg dav dav sib qhia kev sib txuas ntawm kab rov tav, txawm li cas los xij cov kab hluav taws xob dav dav yuav xav tau cov xaim hluav taws xob los txuas tus faib.

Lub suab sensor muaj VCC/5V tus pin (liab), Hauv av/GND tus pin (dub) thiab tus pin tso tawm (Xim). Lawv tuaj yeem muaj Analog thiab/lossis Digital outputs nyob ntawm qhov ntsuas.

Qhov kev pabcuam muaj 5V chaw nres nkoj (liab), Pulse Width Modulation/PWM chaw nres nkoj (xim) thiab av/GND chaw nres nkoj (dub). Nyem qhov txuas kom paub ntau ntxiv txog nws ua haujlwm li cas.

Kauj Ruam 2: Teeb Lub Circuit Court

Kev teeb tsa Circuit
Kev teeb tsa Circuit

Ua raws daim duab kab ke. Thaum teeb tsa lub Circuit Court, nco ntsoov nco ntsoov khaws cov arduino tsis txuas kom tsis txhob muaj kev puas tsuaj rau koj cov khoom. Hauv kev teeb tsa Lub Suab Sensor tau sawv cev los ntawm lub zog ntsuas hluav taws xob vim tias lawv ua haujlwm zoo ib yam li cov cai.

Txuas lub suab ntsuas mus rau hauv txoj kab hluav taws xob ntawm daim ntawv qhia zaub mov, sau tseg ntawm nws txoj kev taw qhia (qhov no yuav yog qhov tseem ceeb thaum siv cov xov hluav taws xob txuas mus txuas rau arduino). Txuas VCC nrog lub xaim liab txuas rau hauv lub khob cij lub qhov hluav taws xob zoo. Txuas GND nrog cov xaim dub txuas rau hauv lub khob cij lub qhov hluav taws xob tsis zoo. Txuas Tawm tus pin nrog cov xim jumper hlau rau hauv Analog Port A5.

Txuas lub servo rau hauv lub khob cij thiab arduino. Siv cov xim jumper hlau los txuas nws cov tswv yim/teeb liab chaw nres nkoj rau digital PWM chaw nres nkoj, 13 ntawm arduino. Txuas cov hlua hluav taws xob dub rau hauv GND fais fab kev tsheb nqaj hlau. Txuas lub xaim jumper hlau liab rau hauv kab dav hlau. Qhov kev pabcuam yuav xav tau lub zog ntxiv uas yog muab los ntawm 9V roj teeb.

Txuas lub 9V roj teeb, xaim xaim xaim liab rau hauv tib lub dav hlau kab ib yam li servo lub xov tooj liab liab txuas. Cov xaim jumper dub yuav ntsaws rau tib txoj kab hluav taws xob ib yam li cov khoom seem.

Kauj Ruam 3: Rub Arduino GUI thiab Cov Cai Siv

Rub tawm Arduino GUI thiab Cov Lus Taw Qhia
Rub tawm Arduino GUI thiab Cov Lus Taw Qhia
Rub tawm Arduino GUI thiab Cov Lus Taw Qhia
Rub tawm Arduino GUI thiab Cov Lus Taw Qhia

Rub tawm Arduino Graphical User Interface (GUI) ntawm no. Plug rau hauv kab ntawv hauv qab no, nco ntsoov cov ntaub ntawv mus rau sab xis ntawm "//" qhia koj tias kab ntawv ntawm txoj cai no ua dab tsi:

#suav nrog

Kev pabcuam servo_test;

const int soundSensor = A5;

int servoPin = 13;

int suabValue;

lub kaum ntse ntse;

void teeb tsa () {

servo_test.attach (servoPin);

Serial.begin (9600);

}

void voj () {

soundValue = analogRead (suab Sensor);

Serial.print ("SoundValue =");

Serial.println (soundSensor);

ncua (50);

kaum = daim duab qhia chaw (soundValue, 0, 1023, 0, 180);

servo_test.write (kaum sab xis);

ncua (50);

}

Kauj Ruam 4: Suab Sensor + Servo + Arduino

Suab Sensor + Servo + Arduino
Suab Sensor + Servo + Arduino
Suab Sensor + Servo + Arduino
Suab Sensor + Servo + Arduino

Nov yog yuav ua li cas qhov kawg ntawm Circuit yuav tsum saib. Saib cov vis dis aus kom pom tias nws ua haujlwm li cas.

Pom zoo: