Nkawd zoo li nws yuav yooj yim dua li txuas lub pob? Txawm li cas los, muaj cov pitfalls ntawm no ib yam nkaus. Cia peb paub tseeb.
Nws yog qhov tsim nyog
- - Arduino;
- - tact khawm;
- - resistor 10 kOhm;
- - khob cij board;
- - txuas xov hlau.
Cov Lus Qhia
Kauj ruam 1
Cov nyees khawm yog qhov sib txawv, tab sis lawv txhua tus ua haujlwm tib yam - lawv lub cev sib txuas (lossis, hloov pauv, tus so) cov coj ua ke muab hluav taws xob sib chwv. Hauv qhov kev yoojyim, qhov no yog qhov sib txuas ntawm ob tus neeg xyuas pib; muaj cov khawm uas txuas ntau tus neeg xyuas pib.
Qee cov nyees khawm, tom qab koj nias, tawm ntawm tus neeg xyuas pib txuas nrog (latching nyees khawm), lwm tus tam sim ntawd qhib lub Circuit Court tom qab tso tawm (tsis-latching).
Kuj, cov nyees khawm tau muab faib ua ib txwm qhib thiab ib txwm kaw. Thawj, thaum nias, kaw lub Circuit Court, qhov qhib thib ob.
Tam sim no cov hom khawm, uas yog hu ua "tact nyees khawm", tau pom cov kev siv dav. Cov tuav tsis yog los ntawm lo lus "tact", tab sis theej los ntawm lo lus "tactile", tk. kev nias yog zoo mloog nrog koj cov ntiv tes. Cov no yog cov nyees khawm uas, thaum nias, kaw qhov hluav taws xob, thiab thaum tso tawm, lawv qhib.
Kauj ruam 2
Lub khawm yog qhov tsim tau yooj yim heev thiab muaj txiaj ntsig zoo uas pabcuam rau kev sib hloov zoo ntawm tib neeg-thev naus laus zis. Tab sis, zoo li txhua yam hauv ntuj, nws tsis zoo tag nrho. Qhov no tau ua pov thawj hauv qhov tseeb tias thaum koj nias lub pob thiab thaum koj tso nws, qhov thiaj hu ua. "bounce" ("bounce" nyob rau hauv lus Askiv). Qhov no yog qhov hloov ntau ntawm lub xeev ntawm lub khawm nyob rau lub sijhawm luv luv (ntawm kev txiav txim ntawm ob peb milliseconds) ua ntej nws kwv yees lub xeev khov kho. Qhov tshwm sim tsis tsim nyog tshwm sim thaum lub caij hloov khawm vim yog qhov ywj ntawm cov ntaub ntawv ntawm lub khawm lossis vim muaj qhov khoob me me uas tshwm sim los ntawm kev siv hluav taws xob.
Koj tuaj yeem pom qhov kev tawm ntawm kev sib cuag nrog koj tus kheej lub qhov muag siv Arduino, uas peb yuav ua me ntsis tom qab.
Kauj ruam 3
Txhawm rau txuas lub sijhawm qhib lub sijhawm khawm mus rau Arduino, koj tuaj yeem ua qhov yooj yim tshaj plaws: txuas ib tus neeg xyuas pib dawb ntawm lub pob mus rau lub zog lossis hauv av, lwm qhov txuas nrog lub koob digital ntawm Arduino. Tab sis feem ntau hais lus, qhov no tsis yog lawm. Qhov tseeb yog tias nyob rau lub sijhawm thaum lub khawm tsis kaw, hluav taws xob cuam tshuam yuav tshwm sim ntawm cov zis digital ntawm Arduino, thiab vim qhov no, lub tswb tsis tseeb yog qhov ua tau.
Txhawm rau kom tsis txhob tuaj tos, lub xov tooj digital feem ntau txuas nrog los ntawm qhov loj txaus resistor (10 kΩ), ya mus rau hauv av lossis rau lub hwj chim sib txuas. Hauv thawj kis, qhov no hu ua "rub tawm resistor Circuit Court", nyob rau hauv ob, "rub tawm" resistor Circuit Court ". Cia peb saib ntawm lawv txhua tus.
Kauj ruam 4
Ua ntej, peb txuas lub pob nyem mus rau Arduino uas yog siv lub tshuab hluav taws xob rub tawm. Txhawm rau ua qhov no, txuas ib qho sib txuas ntawm lub pob mus rau hauv av, thiab lwm qhov rau cov zis digital 2. Digital output 2 tseem txuas nrog los ntawm 10 kOhm resistor mus rau +5 V fais fab mov.
Kauj ruam 5
Cia peb sau cov duab kos rau tuav khawm nyem thiab xa mus rau Arduino.
Qhov ntsuas phoo built-in LED ntawm tus pin 13 yog tam sim no mus tas li kom txog thaum lub pob nyem. Thaum peb nias lub khawm, nws pib qis thiab LED tawm mus.
Kauj ruam 6
Tam sim no peb sib sau lub rub-down resistor Circuit Court. Txuas ib qho sib tiv tauj ntawm lub pob mus rau +5 V fais fab mov, lwm qhov rau cov zis digital 2. Txuas digital cov zis 2 los ntawm 10 kΩ resistor rau hauv av.
Peb yuav tsis hloov pauv sketch.
Kauj Ruam 7
Tam sim no lub LED tua kom txog thaum lub pob nyem.