Cov txheej txheem:

YUAV UA LI CAS RASPBERRY PI TSHUAJ: 5 Kauj Ruam
YUAV UA LI CAS RASPBERRY PI TSHUAJ: 5 Kauj Ruam

Video: YUAV UA LI CAS RASPBERRY PI TSHUAJ: 5 Kauj Ruam

Video: YUAV UA LI CAS RASPBERRY PI TSHUAJ: 5 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
YUAV UA LI CAS THIAJ RASPBERRY PI TSHUAJ
YUAV UA LI CAS THIAJ RASPBERRY PI TSHUAJ

Tej zaum txhua tus neeg siv RPi ib zaug xav paub yuav ua li cas tua Raspberry Pi?

Koj tsis tuaj yeem tsuas yog tua lub zog. Yog tias koj ua li ntawd, nws zoo li ib hnub SD daim npav yuav raug puas ntsoog, thiab koj li RPi yuav tsis pib. Koj yuav tsum xub kaw OS, thiab tsuas yog tom qab ntawd koj tuaj yeem tua nws los ntawm rub lub qaum tawm ntawm lub qhov (socket), lossis yog tias koj yog tus neeg siv ntau dua, los ntawm kev hloov kho los ntawm koj tus kheej. Nws yog ntau dua lossis tsawg dua, yog tias koj siv koj li RPi ua lub desktop PC. Tab sis yuav ua li cas yog tias hauv koj qhov haujlwm tsis yog siv keyboard lossis nas lossis saib?

Kuv qhov kev daws teeb meem yog raws li kev siv Mini Pushbutton Power Switch nrog Rov Qab Tiv Thaiv Kev Tiv Thaiv Pawg. Cia peb nkag mus rau cov ntsiab lus.

Kauj Ruam 1: Kho Koj Tus Raspberry Pi

Ua ntej koj yuav tsum hloov kho cov ntaub ntawv config.txt ntawm koj RPI, los ntawm kev ntxiv kab:

dtoverlay = gpio-poweroff, active_low, gpiopin = 14

Muab kab no rau thaum kawg, ua ntej:

pib_x = 0

Nrog kab no koj teeb GPIO14 (ntawm no Kuv tab tom siv BCM GPIO tus lej) siab thaum pib. Thaum nws yuav qis qis tom qab kaw, nws yuav tua lub zog ntawm tus pin "ctrl" ntawm Pololu board.

Kauj Ruam 2: Txuas Pololu Board rau Koj RPi

Txuas Pololu Board rau Koj RPi
Txuas Pololu Board rau Koj RPi

Txuas Pololu board rau koj RPi raws li nws tau qhia hauv daim duab.

Kauj ruam 3: Python Script

Koj yuav tsum tau ntxiv qee qhov chaws rau koj tsab ntawv Python, ib yam nkaus

.****************************************************************************

gpio.setup (31, gpio. IN, pull_up_down = gpio. PUD_UP) # teeb tsa GPIO 31 raws li kev nkag

def Shutdown (channel): os.system ("sudo kaw -h tam sim no") # kaw RPi ntawm qis GPIO31

gpio.add_event_detect (31, gpio. FALLING, callback = Shutdown, bouncetime = 2000) # tos GPIO qis los kaw RPi

****************************************************************************

Kauj Ruam 4: Nws Ua Haujlwm Li Cas

SW1 hloov ua haujlwm li "ON" khawm. Tsis muaj dab tsi tshwj xeeb, txhua yam yog qhov tseeb:)

Thaum koj nias SW2, kaw cov txheej txheem pib los ntawm kev ua Python tsab ntawv.

Thaum cov txheej txheem tiav, GPIO8 mus qis.

Qib qis ntawm tus pin "ctrl" ntawm Pololu board, tig lub zog.

Qhov ntawd yog:)

Kauj ruam 5: Tsaug

Mus ntsib kuv Blog rau ntau txoj haujlwm txaus nyiam:

verysecretlab09.blogspot.com/

Youtube channel:

www.youtube.com/channel/UCl8RTfbWUWxgglcJM…

Pom zoo: