Cov txheej txheem:
- Kauj Ruam 1: Hluav Taws Xob Hluav Taws Xob
- Kauj ruam 2: Python Code
- Kauj Ruam 3: Yuav Ua Li Cas Tso Tawm Tsab Ntawv Tom Qab Txheej Txheem Khau
Video: Lub Hwj Huam-Tawm Khawm rau Raspberry Pi: 3 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:24
Raspberry Pi yog lub platform siv tau txiaj ntsig zoo uas tso cai tsim ntau yam IoT/neeg hlau/ntse-tsev/… project thov. Ib yam uas nws tsis muaj txawm tias, piv rau lub khoos phis tawj ib txwm, yog kaw lub zog-tua khawm. Yog li peb tuaj yeem tsim ib tus kheej li cas? Yog lawm, cia peb ua nws ua ke!
Rau qhov kev qhia no, koj yuav xav tau cov hauv qab no:
- 1 Raspberry Pi twb tau teeb tsa thiab npaj siv
- 1 lub khob cij los yog qee yam uas yuav tso cai rau koj los tsim hluav taws xob hluav taws xob
- 1 laub-khawm
- 2 jumper xov
Yog tias koj tsis tau siv Raspberry Pi, koj tuaj yeem tshawb xyuas kuv cov lus qhia yuav ua li cas thiab yuav ua dab tsi los teeb tsa nws:
www.instructables.com/How-to-Setup-a-Raspberry-Pi-and-Start-Using-It/
Kauj Ruam 1: Hluav Taws Xob Hluav Taws Xob
Tsis muaj dab tsi nyuab heev ntawm no, nws yog qhov yooj yim Circuit Court. 2 daim duab saum toj no piav qhia txog kev tsim hluav taws xob. Koj tuaj yeem siv qhov twg GPIO tus pin koj xav tau rau lub pob nkag, koj tsuas yog yuav tsum tau ua kom hloov kho cov cai kom muaj kev cuam tshuam qhov ntawd.
Cia peb piav qhia sai npaum li cas qhov no yuav ua haujlwm:
- RED xaim tau noj 3.3V mus rau ib qho kawg ntawm lub laub khawm.
- BLACK cable txuas rau lwm qhov kawg ntawm lub laub khawm mus rau Pi GPIO uas yuav siv los ua tswv yim.
- los ntawm lub neej ntawd lub pob tau qhib, yog li tsis muaj qhov hluav taws xob hla nws. Yog li BLACK cable nyob ntawm 0V thaum lub khawm tsis nias. Qhov no txhais tau tias lub xeev cov ntsiab lus ntawm Pi GPIO cov tswv yim yog 0.
- thaum lub pob yuav raug nias, qhov hluav taws xob yuav hla nws thiab BLACK cable yuav txuas rau 3.3V. Raspberry Pi yuav pom qhov hluav taws xob ntawm 3.3V ntawm nws cov tswv yim, sib thooj rau lub xeev muaj tswv yim ntawm 1.
Kauj ruam 2: Python Code
Tam sim no qhov kev siv hluav taws xob tau npaj siv, peb yuav tsum sau cov cai uas yuav ua nws, thiab kuv siv Python hauv PyCharm ib puag ncig ntawm no. Kuv teeb tsa lub pob kom lub zog-tawm ntawm Raspberry Pi tsuas yog thaum nws raug nias ntau dua 3 vib nas this. Qhov laj thawj yog vim li cas kuv thiaj ua li ntawd yog tias nws yooj yim heev kom nws nias yuam kev, thiab koj tsis xav kaw koj Pi los ntawm kev sib tsoo.
Cov ntawv luam tawm saum toj no yog los ntawm kuv ib puag ncig PyCharm, thiab cov cai yog cov hauv qab no (nrog qhov sib txawv me me ntawm kab 26 uas txuas rau lwm txoj haujlwm tab sis tsis xav tau ntawm no):
# Qhov no yog aa code rau poweroff Raspberry Pi thaum nias thiab tuav lub khawm txhais # Cov khoom siv sab nrauv importimport RPi. GPIO li GPIOimport timeimport os # Raspberry Pi tus pin & cov ntsiab lus hloov pauv txhais & hold_time = 3 # Tuav lub sijhawm hauv sec rau poweroffbutton_poweroff = 1 # Nias khawm txhawm rau tua Raspberry PiGPIO.setwarnings (Cuav) GPIO.setmode (GPIO. BCM) # Broadcom tus lej-tus lej txheej txheem GPIO.setup (button_poweroff, GPIO. IN, pull_up_down = GPIO. PUD_DOWN) # Khawm teeb raws li kev nkag siab tseeb: GPIO.wait_for_edge (button_poweroff, GPIO. RISING) pib = time.time () time.sleep (0.2) # Hloov debounce thaum GPIO.input (button_poweroff) == 1: time.sleep (0.01) ntev = time.time () - pib yog ntev > tuav_time: os.system ("sudo poweroff")
Thawj qhov, yog tias koj tau txuas lub laub khawm mus rau GPIO sib txawv, yog hloov kho kab 11 ntawm cov ntawv sau saum toj no nrog cov ntsiab lus cuam tshuam GPIO:
button_poweroff = GPIO_X # Hloov kho nrog qhov tseeb GPIO siv rau hauv koj lub Circuit Court
Tsis tas li, qhov tuav tuav lub sijhawm tso cai rau koj hloov kho lub sijhawm tos uas ua rau Pi kaw.
Kauj Ruam 3: Yuav Ua Li Cas Tso Tawm Tsab Ntawv Tom Qab Txheej Txheem Khau
Tam sim no tias peb muaj cov cai npaj, peb tsuas yog yuav tsum tau ua nws. Tab sis, nws yuav yooj yim yog tias peb tuaj yeem ua tsab ntawv no ua tiav txhua lub sijhawm Pi tau pib, nyob rau hauv txoj kev tsis siv neeg, yog li lub pob yuav ua haujlwm yam tsis muaj peb kom khiav tsab ntawv txhua lub sijhawm. Muaj ntau txoj hauv kev los ua. Kuv tau ntxiv ntawm no ib kab rau hauv rc.local cov ntaub ntawv uas nyob hauv / etc / folder ntawm koj Pi. Nws tau ua tiav raws li ib feem ntawm cov khau raj sib lawv liag.
Koj yuav tsum qhib kab hais kom ua thiab ntaus cov lus txib hauv qab no (1st printscreen saum toj no):
cd / cov
cd thiab lwm yam sudo nano rc.local
Thawj lo lus txib yuav coj koj los ntawm koj /tsev /pi phau ntawv teev npe mus rau lub hauv paus, uas yog /.
Qhov lus txib thib ob yuav coj koj mus rau / etc / directory.
Thaum kawg, tus thib peb yuav qhib rc.local cov ntaub ntawv ua tus siv superuser, nrog rau txoj cai hloov pauv tag nrho, uas koj yuav tsum hloov kho cov ntaub ntawv.
Ib zaug hauv cov ntawv, koj tsuas yog xav tau ntxiv kab ntawm qhov kawg ntawm nws, tab sis ua ntej tawm lus 0 nqe lus (2nd printscreen saum toj no):
# Ntxiv kab ntawv no rau rc.local cov ntaub ntawv kom qhib tsab ntawv
sudo python /home/pi/Documents/shutdown_with_hold.py &
Muaj qee yam uas koj yuav tsum tau ua tib zoo saib, ntawm no:
- lub npe ntawm koj cov ntaub ntawv: hauv kab saum toj no, Kuv xav tias cov ntaub ntawv raug kaw_with_hold.py. Tab sis nws tuaj yeem yog txhua yam koj xav tau, tsuas yog hloov lub npe nrog koj li.
- qhov twg koj tau khaws koj cov ntaub ntawv: hauv kab saum toj no, Kuv xav tias nws tau khaws tseg hauv koj/tsev/pi/Cov ntawv teev npe. Tab sis ntxiv, nws tuaj yeem nyob txhua qhov chaw. Koj tsuas yog yuav tsum paub tseeb tias yuav muab txoj hauv kev rau koj cov ntaub ntawv ntawm no.
- tus cim "&" qhov kawg ntawm nws: qhov no yog qhov tseem ceeb, thiab nws tso cai rau qhov kev hais kom ua no rau tom qab
Thiab qhov ntawd yog nws! Yog li tam sim no, tsab ntawv yuav ua tiav txhua lub sijhawm koj Pi yuav ON, thiab koj tsuas yog yuav tsum tau nyem ntau dua 3 vib nas this ntawm lub pob kom tua nws.
Pom zoo:
Lub Hwj Huam Lub Hwj Huam: 6 Kauj Ruam (nrog Duab)
Lub Hwj Huam Fais Fab Lub Rooj Zaum: Hauv cov lus qhia no kuv yuav qhia koj yuav ua li cas tsim lub rooj zaum siv hluav taws xob siv qee qhov yooj yim tawm ntawm cov khoom txee thiab kev cai luam tawm 3D cov ntaub ntawv. Lub hom phiaj yog ua kom lub zog me me thiab zoo saib lub zog uas muaj zog txaus rau feem ntau ap
Lub Hwj Huam Muaj Hwj Huam LED Tsav Tsheb: 12 Cov Kauj Ruam (nrog Duab)
Lub Hwj Huam Muaj Hwjchim Loj LED Tsav Tsheb: Lub Hwjchim Loj LED: lub teeb pom kev yav tom ntej! tab sis … koj siv lawv li cas? koj tau lawv nyob qhov twg? 1-watt thiab 3-watt Power LED's tam sim no muaj dav nyob hauv $ 3 txog $ 5 ntau, yog li kuv tau ua haujlwm ntawm cov phiaj xwm tsis ntev los no uas siv lawv. hauv pro
Hloov Lub Cordless Lub Hwj Huam Lub Hwj Huam Roj Teeb kom Ua Haujlwm Nrog Phab Ntsa Tam Sim No: 5 Kauj Ruam
Hloov Cordless Lub Cuab Yeej Siv Hluav Taws Xob Roj Teeb kom Siv Nrog Phab Ntsa Tam Sim No: NCO TSEG: Kuv tau sau qhov no ible ua ntej kuv tau nkag siab zoo txog hluav taws xob. Nov yog lub tswv yim tsis zoo thiab feem ntau yuav ua rau koj lub roj teeb puas tsuaj. Nws zoo li ntse thaum lub sijhawm. Huag zoo, nyob thiab kawm. Ntxiv lub jack rau lub roj teeb ntawm cor
IKEA Lub Hwj Huam Lub Hwj Hwj Nrog Tus Kheej Hloov: 6 Cov Kauj Ruam (nrog Duab)
IKEA Lub Hwj Chim Them Lub Box Nrog Tus Kheej Tus Kheej: Yog li lwm hnub kuv tau pom cov lus qhia no yuav ua li cas thiaj ua tau qhov chaw nres tsheb yooj yim siv IKEA lub thawv: Lub-IKEA-charging-box --- tsis-ntau-cable-mess! qee yam zoo sib xws, yog li kuv tau mus thiab yuav ib lub thawv ntawm IKEA, tab sis nws sawv ntawm kuv tawm
Hloov Belkin FM Transmitter Los Ntawm Lub Hwj Huam Lub Hwj Chim rau Lub Hwj Chim Tsheb: 8 Kauj Ruam
Hloov Belkin FM Transmitter Los Ntawm Roj Teeb Hluav Taws Xob rau Lub Tsheb Fais Fab: Kuv muaj ib tus thawj Belkin Tunecast FM transmitters rau kuv iPod. Tom qab kuv pub nws ib khub AA roj teeb kuv txiav txim siab kuv xav tau txoj hauv kev zoo dua. Yog li, ntawm no yog yuav ua li cas kuv hloov lub tsheb luam yeeb lub teeb txawb lub xov tooj ntawm tes rau hauv ib txoj hauv kev los txhawb kuv lub tsheb