Cov txheej txheem:

Txee Siv Pushbutton - Tinker Cad: 3 Kauj Ruam
Txee Siv Pushbutton - Tinker Cad: 3 Kauj Ruam

Video: Txee Siv Pushbutton - Tinker Cad: 3 Kauj Ruam

Video: Txee Siv Pushbutton - Tinker Cad: 3 Kauj Ruam
Video: Tinkercad + Arduino Lesson 3: Pushbuttons 2024, Hlis ntuj nqeg
Anonim
Image
Image
Cov Cheeb Tsam Yuav Tsum Tau
Cov Cheeb Tsam Yuav Tsum Tau

Thaum koj tau txais lub laub khawm ua haujlwm, koj feem ntau xav ua qee yam ua raws li pes tsawg zaus khawm raug thawb. Txhawm rau ua qhov no, koj yuav tsum paub thaum lub khawm hloov lub xeev los ntawm kev mus rau, thiab suav pes tsawg zaus qhov kev hloov pauv ntawm lub xeev tshwm sim. Qhov no hu ua kev hloov pauv hauv xeev lossis kuaj pom ntug. Hauv qhov kev qhia no peb kawm paub yuav tshuaj xyuas lub xeev kev hloov pauv li cas, peb xa xov mus rau Serial Monitor nrog cov ntaub ntawv cuam tshuam thiab peb suav plaub lub xeev hloov pauv kom qhib thiab tua lub LED.

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 xov hlau

Kauj Ruam 2: Daim Duab Circuit:

Image
Image

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:

Facebook nplooj ntawv:

Instagram:

int khawm = 2;

int ib, i = 0; teeb tsa tsis muaj dab tsi () {Serial.begin (9600); pinMode (khawm, INPUT); } void loop () {a = digitalRead (khawm); yog (a == 1) {i = kuv+1; Serial.print ("Counter ="); Serial.println (kuv); } lwm {i = 0; }}

Pom zoo: