Cov txheej txheem:

Raspberry Pi Tutorial: Yuav Siv Li Cas Push: 4 Kauj Ruam
Raspberry Pi Tutorial: Yuav Siv Li Cas Push: 4 Kauj Ruam

Video: Raspberry Pi Tutorial: Yuav Siv Li Cas Push: 4 Kauj Ruam

Video: Raspberry Pi Tutorial: Yuav Siv Li Cas Push: 4 Kauj Ruam
Video: Начало → Изучайте английский → Освойте ВСЕ ОСНОВЫ АНГЛИЙСКОГО ЯЗЫКА, которые вам НУЖНО знать! 2024, Kaum ib hlis
Anonim
Raspberry Pi Tutorial: Yuav Siv Li Cas Push
Raspberry Pi Tutorial: Yuav Siv Li Cas Push

Hauv qhov kev qhia no koj yuav kawm paub yuav ua li cas hloov koj lub LED siv lub pob nrog koj li Raspberry Pi. Laub cov nyees khawm lossis hloov pauv txuas ob lub ntsiab lus hauv Circuit Court thaum koj nias lawv. Cov ntawv qhia no tig rau ib qho LED thaum lub pob nyem ib zaug, thiab tawm thaum nias ob zaug. Koj tseem yuav kawm paub siv 'tus chij' sib txawv los tswj qhov xwm txheej.

Tutorial tshiab thiab ntau Raspberry Pi tutorials tuaj yeem pom ntawm no:

www.ardumotive.com/how-to-use-push-buttonen…

Video hauv lus Greek

Cia peb pib!

Kauj Ruam 1: Yam Koj Yuav Tsum Xav Tau - Kho vajtse

Rau qhov kev qhia no koj yuav xav tau:

  • GPIO Kev Tawm Tsam
  • Cov qhob cij
  • LED
  • 220 Ohm tus tiv thaiv
  • Khawm

Kauj ruam 2: Circuit Court

Qhov Circuit
Qhov Circuit

Cov kev sib txuas yog yooj yim zoo nkauj, saib cov duab saum toj no nrog cov phiajcim breadboard.

Kauj Ruam 3: Txoj Cai

Hauv qhov haujlwm hauv qab no, thawj qhov koj ua yog ntshuam lub tsev qiv ntawv rau GPIO thiab tsaug zog. Cov kauj ruam tom ntej yog teeb tsa tus pin ntawm LED thiab Khawm. Tom qab qhov teeb tsa khawm ua lub tswv yim thiab LED ua qhov tso tawm. Lub sijhawm True loop khiav dhau mus thiab ntau dua, mus ib txhis. Tsis tas li koj tuaj yeem tig koj lub LED nrog ob txoj hauv kev. Thawj txoj hauv kev yog LED teeb tsa kom ntev li ntev tau khawm lub pob thiab txoj kev thib ob yog tias koj nias ib zaug xwb lub pob ntawd koj pom koj lub LED qhib thiab yog tias koj nias lub pob dua ces LED tawm. Txoj hauv kev thib ob yog ntawm cov lus ('' ') thiab peb siv qhov sib txawv uas muaj npe chij.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

#Libraries

ntshuam RPi. GPIO li GPIO los ntawm lub sijhawm ntshuam #Set cov lus ceeb toom tawm (yeem) GPIO.setwarnings (Cuav) GPIO.setmode (GPIO. BCM) #Set Button and LED pins Button = 23 LED = 24 #Setup Button and LED GPIO. teeb tsa (Khawm, GPIO. IN, rub_up_down = GPIO. PUD_UP) GPIO.setup (LED, GPIO. OUT) #flag = 0 thaum Tseeb: button_state = GPIO.input (Khawm) luam tawm (button_state) yog button_state == 0: GPIO.output (LED, GPIO. HIGH) lwm qhov: GPIO.output (LED, GPIO. LOW) pw (1) '' 'yog button_state == 0: pw (0.5) yog chij == 0: chij = 1 ntxiv: chij = 0 yog tus chij == 1: GPIO.output (LED, GPIO. HIGH) ntxiv: GPIO.output (LED, GPIO. LOW) '' '

Rub tawm cov cai los ntawm no thiab qhib nws nrog Thonny Python IDE lossis khiav nws los ntawm lub davhlau ya nyob twg.

Kauj ruam 4: Ua tau zoo

Ua Tau Zoo!
Ua Tau Zoo!

Koj tau ua tiav peb thawj Raspberry Pi "Yuav ua li cas" qhia thiab koj tau kawm paub yuav ua li cas hloov ntawm LED nrog lub pob.

Pom zoo: