Cov txheej txheem:

Interfacing Pushbutton - Arduino Basics: 3 Kauj Ruam
Interfacing Pushbutton - Arduino Basics: 3 Kauj Ruam

Video: Interfacing Pushbutton - Arduino Basics: 3 Kauj Ruam

Video: Interfacing Pushbutton - Arduino Basics: 3 Kauj Ruam
Video: Tinkercad + Arduino Lesson 3: Pushbuttons 2024, Kaum ib hlis
Anonim
Image
Image
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau

Lub laub khawm yog ib feem uas txuas ob lub ntsiab lus hauv Circuit Court thaum koj nias nws.

Thaum lub laub khawm qhib (tsis muaj kev nyuaj siab) tsis muaj kev sib txuas ntawm ob txhais ceg ntawm lub laub, yog li tus pin txuas nrog 5 volts (los ntawm kev rub tawm tus tiv thaiv) thiab peb nyeem HIGH. Thaum lub pob raug kaw (nias), nws ua rau muaj kev sib txuas ntawm nws ob txhais ceg, txuas tus pin rau hauv av, kom peb nyeem LOW. (Tus pin tseem txuas nrog 5 volts, tab sis tus tiv thaiv hauv nruab nrab ntawm lawv txhais tau tias tus pin "ze" rau hauv av.)

Kauj Ruam 1: Cov Cheeb Tsam Yuav Tsum Tau:

Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau

1. Arduino UNO

2. Cov qhob cij

3. Pushbutton

4. Resistor

5. Jumper hlau

Kauj Ruam 2: Daim Duab Circuit:

Daim duab kos duab
Daim duab kos duab

Txuas peb xov hlau mus rau lub rooj tsavxwm. Thawj mus los ntawm ib txhais ceg ntawm lub pob nyem los ntawm kev rub tawm tus tiv thaiv (ntawm no 10k ohm) mus rau hauv av. Qhov thib ob mus los ntawm cov ceg sib txuas ntawm lub khawm mus rau 5 qhov hluav taws xob. Qhov thib peb txuas rau tus lej I/O tus lej (ntawm tus pin 2) uas nyeem lub pob lub xeev.

Thaum lub laub khawm qhib (tsis muaj kev nyuaj siab) tsis muaj kev sib txuas ntawm ob txhais ceg ntawm lub laub khawm, yog li tus pin txuas nrog hauv av (dhau qhov rub tawm tus neeg tawm tsam) thiab peb nyeem LOW. Thaum lub pob raug kaw (nias), nws ua rau muaj kev sib txuas ntawm nws ob txhais ceg, txuas tus pin rau qhov hluav taws xob, kom peb nyeem HIGH. (Tus lej tseem txuas nrog hauv av, tab sis tus tiv thaiv tiv thaiv cov dej ntws tam sim no, yog li txoj hauv kev tiv thaiv tsawg kawg yog +5V.) Yog tias koj txuas tus lej I/O tus pin los ntawm txhua yam, LED tuaj yeem ntsais muag tsis raug. Qhov no vim tias cov tswv yim yog "ntab" - uas yog, tsis txuas nrog rau qhov hluav taws xob lossis hauv av. Nws yuav ntau dua lossis tsawg dua qhov rov qab los yog HIGH lossis LOW. Tias yog vim li cas koj thiaj xav tau rub tawm tus tiv thaiv hauv Circuit.

Kauj ruam 3: Code:

Yog xav paub ntau cov phiaj xwm txuas nrog kuv ntawm:

Youtube: https://www.youtube.com/channel/UCTS10_CRYJhT-vb9 … Facebook nplooj:

Instagram: https://instagram.com/official_techeor? Igshid = uc8…

int khawm = 2;

int ib; teeb tsa tsis muaj dab tsi () {Serial.begin (9600); pinMode (khawm, INPUT); } void loop () {a = digitalRead (khawm); Serial.print ("Tus nqi ntawm khawm ="); Serial.println (a); }

Pom zoo: