Cov txheej txheem:

Tswb Tswb Tswb Tswb Tswb Ntse Teeb: 8 Kauj Ruam (nrog Duab)
Tswb Tswb Tswb Tswb Tswb Ntse Teeb: 8 Kauj Ruam (nrog Duab)

Video: Tswb Tswb Tswb Tswb Tswb Ntse Teeb: 8 Kauj Ruam (nrog Duab)

Video: Tswb Tswb Tswb Tswb Tswb Ntse Teeb: 8 Kauj Ruam (nrog Duab)
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Hlis ntuj nqeg
Anonim
Tswb Tswb Tswb Tswb Ntse Teeb
Tswb Tswb Tswb Tswb Ntse Teeb
Tswb Tswb Tswb Tswb Ntse Teeb
Tswb Tswb Tswb Tswb Ntse Teeb
Tswb Tswb Tswb Tswb Ntse Teeb
Tswb Tswb Tswb Tswb Ntse Teeb

Hauv qhov haujlwm no kuv upcycle lub tswb cua tawg tag. Lub ntsej muag ntawm lub moos tau hloov pauv los ntawm 12 LEDs, teeb pom kev los ntawm LED kab ib ncig ntawm ntug ntawm lub moos. 12 LEDs qhia lub sijhawm thiab cov hlua LED tau teeb tsa los ua lub tswb, tig mus rau qhov ci tag nrho ntawm lub sijhawm teev tseg. Txhua yam yog tswj los ntawm Raspberry Pi Zero tso cai rau suav nrog suav tsis txheeb thiab nthuav tawm qhov muaj peev xwm xws li cia li synchronizing lub teeb tswb nrog koj lub xov tooj tswb lossis teeb lub LED thaum koj tau txais email.

Txoj haujlwm siv cov khoom pheej yig lossis rov qab siv dua - qhov tsuas yog qhov uas kuv tau mus yuav yog qhov ntsuas hluav taws xob. Txhua yam ntxiv uas kuv tau tshwm sim tau dag ib puag ncig xws li txiav tawm ntawm LED sawb. Cov Lus Qhia no yuav coj koj mus txog qhov kuv tau muab lub neej tshiab rau kuv lub moos tawg thiab vam tias yuav txhawb koj kom siv qee yam ntawm koj tus kheej.

Kauj Ruam 1: Qhov Chaw

Qhov
Qhov
Qhov
Qhov
Qhov
Qhov

Txhawm rau tswj txhua yam peb yuav siv Raspberry Pi Zero raws li nws me me, tus nqi tsawg heev thiab tuaj yeem txuas nrog WiFi uas txhais tau tias peb tsis xav tau raws li lub sijhawm tiag tiag thiab yog li ntawd tuaj yeem hloov kho qhov chaws tau yooj yim dua ntawm lub khoos phis tawj. Tshwj tsis yog tias koj muaj Pi Zero W, peb yuav txuas rau WiFi network siv USB WiFi dongle.

Nov yog cov npe ntawm cov khoom kuv tau siv tab sis ntau yam tuaj yeem hloov pauv rau lwm txoj hauv kev uas tsim nyog. Piv txwv li hloov pauv ntawm Raspberry Pi koj tuaj yeem siv Arduino nrog lub sijhawm tiag tiag los tswj txoj haujlwm.

Qhov siv

  • Lub tswb qub
  • 30cm sov sov dawb LED sawb
  • 1x Raspberry Pi Zero + micro SD daim npav
  • 1x USB WiFi dongle + micro USB rau USB hloov pauv
  • 12 x LEDs
  • 12x 330ohm resistors (siv siab dua yog tias koj xav dimmer LEDs)
  • 1x TIP31a (lossis lwm lub npn zog transistor lossis MOSFET)
  • 1 x 1 k resistor
  • 1x LM2596 DC-DC adjustable buck converter (nqis nqis 12V rau 5V rau Raspberry Pi)
  • 1x12v fais fab mov (+ txoj kev nkag mus rau hauv koj qhov project)
  • 10cm x 10cm ntoo rau lub ntsej muag ntawm lub moos (yuav tsum yog qhov tsim nyog nyias txhawm rau txhim kho koj cov LEDs hauv)
  • Ntau daim ntawm cov xim sib txawv xim

Cov khoom muaj txiaj ntsig kom muaj

  • Soldering hlau + solder
  • Kub kua nplaum
  • Multimeter
  • Cov qhob cij
  • Poj niam header pins
  • Micro SD daim npav nyeem ntawv lossis hloov pauv
  • Ib lub computer
  • Mini HDMI adapter + HDMI npo yog tias koj xav siv Pi lub desktop ib puag ncig

Kauj Ruam 2: Teeb Kho Raspberry Pi

Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi
Teeb tsa Raspberry Pi

Operating System

Vim tias Raspberry Pi yuav tsis txuas nrog lub vijtsam, Kuv tau xaiv siv Raspbian Buster Lite uas tsis tuaj nrog lub desktop ib puag ncig. Yog tias koj tshiab rau Raspberry Pi koj yuav xav ua raws li tus qauv Raspbian Buster uas los nrog lub desktop. Yog tias koj tsis paub yuav teeb tsa koj li kev ua haujlwm li cas, qhov no yog cov peev txheej zoo. Ob lub tshuab ua haujlwm tuaj yeem rub tawm los ntawm Raspberry Pi lub vev xaib.

Rau lub sijhawm tam sim no, fais fab Pi ntawm nws lub zog Micro USB. Kuj txuas mus rau USB WiFi dongle.

Tham nrog Raspberry Pi

Thaum txhua yam tau ntim lawm nws nyuaj rau nkag mus rau Pi yog tias koj xav hloov txoj cai thiab lwm yam. Siv SSH cia siv txuas rau Pi thiab tswj nws los ntawm lwm lub khoos phis tawj. Qhov no tsis tau qhib los ntawm lub neej ntawd tab sis peb tuaj yeem ua los ntawm kev yooj yim ua daim nplaub tshev hu ua ssh hauv qhov muab faib ntawm koj daim npav SD. Yog tias koj twb tau nkag mus rau hauv koj Pi koj tseem tuaj yeem ua qhov no los ntawm kev sau sudo raspi-teeb tsa hauv Terminal thiab mus rau Kev Sib Txuas Xaiv> SSH thiab xaiv Yog los pab nws.

Tam sim no koj tuaj yeem txuas rau koj Pi ntawm lwm lub khoos phis tawj. Ntawm Mac lossis Linux koj tuaj yeem siv koj daim ntawv thov davhlau ya nyob twg tab sis feem ntau ntawm Windows koj yuav tsum teeb tsa SSH tus thov kev pab xws li PuTTY. Txuas mus rau Pi los ntawm kev ntaus ssh pi@ qhov chaw hostname hloov pauv nrog lub hostname ntawm IP chaw nyob ntawm koj Pi. Lub npe hostname tsis raug yog raspberrypi.local. Nws yuav nug koj txog tus password uas, yog tias koj tseem tsis tau hloov nws, yog raspberry.

Txhim kho cov khoom xav tau

Ua ntej ua kom ntseeg tau tias txhua yam tau hloov kho tshiab los ntawm kev khiav sudo apt hloov tshiab thiab tom qab ntawd sudo apt puv-txhim kho.

Kom paub tseeb tias peb yuav tsum tswj hwm GPIO pins ntawm Pi hom sudo apt-get install python-rpi.gpio thiab sudo apt-get install python3-rpi.gpio. Cov no yuav tsum tau teeb tsa tag nrho ntawm Raspbian version.

Cov cai

Nov yog cov cai rub tawm kom nws ua haujlwm txhua. Yog tias koj siv lub desktop ib puag ncig muab cov no tso rau hauv koj Cov Ntawv Teev Npe.

Yog tias koj siv kab hais kom ua ntawm SSH, mus rau koj lub tsev ntawv tais ceev tseg los ntawm kev ntaus cd ~/Cov Ntaub Ntawv thiab nias nkag mus. Ua ib daim ntawv tshiab hu ua test1.py nrog nano test1.py. Qhov no yuav qhib nano ntawv kho qhov twg koj tuaj yeem muab tshuaj txhuam hauv cov cai ntawm rub tawm test1.py. CTRL-O thiab nias nkag mus khaws cov ntaub ntawv thiab CTRL-X kom txiav tawm tus kws kho mob. Rov ua cov txheej txheem rau cov ntaub ntawv tseem tshuav.

Kauj Ruam 3: Txhim Kho LED Sawb

Txhim kho LED Sawb
Txhim kho LED Sawb
Txhim kho LED Sawb
Txhim kho LED Sawb

Ua ntej tshaj tawm cov kab hlua LED hauv lub moos kom pom ntau npaum li cas koj yuav xav tau, kos qhov ntev no thiab txiav kab txaij ntawm qhov txiav tom ntej raws li qhia. Nws yog qhov yooj yim dua los xaim cov xov hlau rau kab sawb ua ntej kab txaij tau daig hauv qhov chaw. Nov yog cov lus qhia zoo nkauj yuav ua li cas ua li no tab sis yog tias koj tsis paub tseeb tias kuv tsuas yog siv rau ntawm cov laug txuas nrog ntawm daim uas koj nyuam qhuav txiav koj cov hlua los ntawm. Siv ib lub xaim rau qhov taw tes zoo thiab ib lub xaim rau qhov tsis zoo. Xyuas kom tseeb tias koj sim koj cov hlua LED ua haujlwm ua ntej koj lo nws hauv koj lub moos.

Txij li cov kab hluav taws xob LED kuv tau siv tau siv ua ntej nws tau poob nws tus kheej nplaum thim rov qab yog li kuv yuav tsum siv cov kua nplaum kub los kho kab txaij nyob ib puag ncig ntawm lub moos. Yog tias koj muaj qhov ntev tshaj, npog qhov chaw uas cov xov hlau txuas. Tej zaum koj yuav xav teeb tsa kab txaij tom qab tab sis kuv pom nws yooj yim dua kom nws ntsaws rau hauv lub moos.

Kauj Ruam 4: Tswj LED Sawb

Tswj LED Sawb
Tswj LED Sawb

Txuas cov hlua LED

Cov hlua LED khiav ntawm 12V yog li tsis tuaj yeem siv tau los ntawm Pi ncaj qha. Txhawm rau tswj lawv peb yuav siv lub zog transistor (piv txwv li TIP31a) txuas nrog rau Pi raws li qhia saum toj no. Kuv xav kom xub xub txheeb xyuas txhua yam no ua haujlwm ntawm lub khob cij.

  • Txuas GPIO 19 mus rau lub hauv paus los ntawm 1k resistor
  • Lub emitter yuav tsum txuas nrog GND
  • Txuas tus neeg khaws khoom mus rau qhov tsis zoo ntawm LED sawb
  • Txuas qhov zoo ntawm LED sawb dav hlau mus rau +12V

Kev Xeem

Hauv kab hais kom ua nagivate rau koj cov ntawv tais ceev tseg (cd ~/Cov Ntaub Ntawv) thiab ntaus nab hab sej test1.py thiab nkag mus. Koj yuav tsum pom LED sawb nce thiab txo qhov ci. Txhawm rau txiav tawm txoj haujlwm, nyem CTRL-C. Koj tuaj yeem hloov kho cov ntaub ntawv (nano test1.py) los hloov qhov nrawm thiab ci ntsa iab hauv qhov haujlwm.

ntshuam RPi. GPIO li GPIOimport lub sij hawm GPIO.setmode (GPIO. BCM) # Siv BCM pinout GPIO.setwarnings (Cuav) # Tsis quav ntsej cov lus ceeb toom txog pins raug siv rau lwm yam khoom ledStripPin = 19 # LED sawb tau tsav los ntawm tus pin GPIO.setup (ledStripPin, GPIO. OUT) # Teeb ledStripPin ua cov zis pwm = GPIO. PWM (ledStripPin, 100) # PWM ntawm ledStripPin nrog zaus 100Hz dutyCycle = 0 # Pib qhov ci ci li feem pua pwm.start (dutyCycle) sim: thaum Tseeb: dutyCycle in range (0, 101, 1): # Fade up pwm. ChangeDutyCycle (dutyCycle) time.sleep (0.05) for dc in range (95, -1, -1): # Fade down pwm. ChangeDutyCycle (dc) sijhawm.sleep (0.05) tshwj tsis yog KeyboardInterrupt: # Nias CTRL-C kom txiav luam yeeb, thiab tom qab ntawd: pwm.stop () # Nres pwm GPIO.cleanup () # Ntxuav cov GPIO pins

Kauj Ruam 5: Ua Lub Ntsej Muag Clock

Ua Lub Ntsej Muag Clock
Ua Lub Ntsej Muag Clock
Ua Lub Ntsej Muag Clock
Ua Lub Ntsej Muag Clock
Ua Lub Ntsej Muag Clock
Ua Lub Ntsej Muag Clock

Txiav daim ntoo rau koj lub moos ntsej muag kom loj npaum li nws haum rau hauv koj lub moos. Kuv ua rau kuv so ntawm 3cm ntawm sab xub ntiag. Laum 12 qhov taub ntawm koj cov LEDs (feem ntau 3mm lossis 5mm) sib nrug 30 degrees ntawm ib leeg. Xuab zeb lub ntsej muag pem hauv ntej thiab ua tiav qhov koj xaiv. Los ntawm sab nraub qaum tso cov LEDs kom lawv taw tes hla mus rau hauv ntej. Kuv siv cov kua nplaum kub kom cov LEDs nyob hauv qhov chaw nrog lub davhlau ya nyob twg zoo (ntev xaim) tig mus rau sab hauv. Qhov loj ntawm kuv lub ntsej muag lub ntsej muag txhais tau tias kuv tuaj yeem siv tag nrho qhov tsis zoo ua ke (saib saum toj no) yog li tsuas yog ib lub xaim xav tau los txuas txhua 12 LEDs rau GND. Tom ntej no, txhuam cov xaim rau txhua LED.

Yog tias koj xav ntsuas qhov no ntawm lub khob cij ua ntej nco ntsoov siv tus tiv thaiv (330ohm yog tus qauv zoo nkauj) hauv koob nrog txhua LED ua ntej koj txuas nws mus rau ib qho ntawm Pi GPIO pins. Ua si ib puag ncig nrog tus nqi ntawm tus tiv thaiv koj siv kom tau txais qib ci ntsa iab uas koj zoo siab nrog. T-cobbler yog qhov muaj txiaj ntsig zoo rau kev rhuav tshem Pi's pins mus rau lub khob cij txawm hais tias koj yuav xav tau cov laug txuas rau ntawm qhov no. Siv test2.py (khiav siv nab hab sej test2.py) tab sis xyuas kom tseeb tias koj xub kho qhov program thiab nkag mus rau Pi's GPIO pins koj tau siv rau txhua lub LED.

ntshuam RPi. GPIO ua GPIO

lub sij hawm ntshuam GPIO.setmode (GPIO. BCM) # Siv BCM pinout GPIO.setwarnings (Cuav) # Tsis quav ntsej cov lus ceeb toom txog tus pin tau siv rau lwm yam # Hloov ib, ob,… nrog tus lej tus lej teev hourPin = [ib, ob, peb, plaub, tsib, rau, xya, yim, cuaj, kaum, kaum ib, kaum ob] # Cov pins LEDs txuas nrog los ntawm 1-12 rau kuv hauv ntau (0, 12): GPIO.setup (hourPin , GPIO. OUT) # Teem tag nrho cov hourPins raws li GPIO.output (hourPin , 0) # Xyuas kom tag nrho cov LEDs raug sim: thaum muaj tseeb: rau kuv hauv ntau (0, 12) GPIO.output (hourPin , 1): sijhawm.sleep (0.05) rau kuv hauv ntau (0, 12) GPIO.output (hourPin , 0): time.sleep (0.05) tshwj tsis yog KeyboardInterrupt: # Nias CTRL-C kom txiav luam yeeb, thiab tom qab ntawd: GPIO.cleanup () # Ntxuav cov GPIO pins

Kauj Ruam 6: Ua kom Pi

Kev txhawb zog Pi
Kev txhawb zog Pi

Peb xav tau txoj hauv kev yooj yim kom tau txais 5V rau Pi Zero yog li peb tuaj yeem tshem tawm ntawm micro USB cable uas peb tau siv los txhawb nws kom deb li deb. Muaj ntau qhov kev daws teeb meem uas nqis qis 12V mus rau 5V xws li LM7805 txoj kab hluav taws xob tawm ncaj qha tab sis cov no tsis muaj txiaj ntsig zoo yog li ntawd es tsis yog kuv xaiv siv qhov hloov pauv hloov pauv tau yooj yim dua siv LM2596 nti. NB nrog qhov no koj yuav tau ntswj lub hwj chim kom txog thaum qhov hluav taws xob tso tawm tau qis dua 5V raws li qhov xav tau yog li koj yuav xav tau qee txoj hauv kev ntsuas qhov hluav taws xob.

Siv LM2596 yog qhov yooj yim: txuas lub +12V rau IN +, hauv av rau IN-. Tus Pi tuaj yeem txuas ncaj qha rau 5V los ntawm kev txuas tawm+ rau ib qho ntawm Pi's 5V tus pin tab sis nco ntsoov tias koj tau hloov pauv qhov hluav taws xob rau 5V ua ntej koj ua qhov no lossis koj yuav kib koj Pi!

Kauj Ruam 7: Ua kom tiav Circuit Court thiab Ntim

Ua kom tiav Circuit Court thiab Ntim
Ua kom tiav Circuit Court thiab Ntim
Ua kom tiav Circuit Court thiab Ntim
Ua kom tiav Circuit Court thiab Ntim
Ua kom tiav Circuit Court thiab Ntim
Ua kom tiav Circuit Court thiab Ntim
Ua kom tiav Circuit Court thiab Ntim
Ua kom tiav Circuit Court thiab Ntim

Tam sim no peb tau npog tag nrho peb lub ntsiab lus ntawm Circuit uas tau qhia ua ke hauv txhua qhov kev sib tham saum toj no. Txhawm rau txuag qhov chaw thiab ua kom muaj kev sib txuas hauv Circuit Court tso koj lub Circuit Court rau ntawm lub rooj tsav nkoj lossis lub rooj tsav tsheb qauv. Ua ntej siv cov khoom me tshaj plaws, cov neeg tawm tsam, tom qab ntawd lub zog transistor, ib qho txuas thiab thaum kawg cov xov hlau. Npaj tawm koj lub voj voog ua ntej koj yuav laug kom paub tseeb tias koj tau txais chaw seem rau txhua yam.

Kuv txuas txhua yam ntawm tus qauv PCB thiab siv poj niam header pins kom Pi tuaj yeem ncaj qha mus rau PCB. Cov LEDs ntawm lub ntsej muag ntawm lub moos tau txuas nrog los ntawm cov neeg tawm tsam ntawm ib sab ntawm pawg thawj coj saib thiab kuv tau khaws qhov chaw nyob ntawm lwm sab ntawm pawg thawj coj rau lub zog hluav taws xob thiab tsis pub dawb rau lwm qhov kev txuas kuv yuav xav ntxiv tom qab.

Txuas lub ntsej muag ntawm lub moos thiab ua kom ntseeg tau tias cov khoom siv hluav taws xob haum txhua qhov. Txhua yam tau nruj heev rau kuv yog li koj yuav xav tau qee qhov rov kho dua. Txuas cov khoom siv hluav taws xob thiab khiav test1.py thiab test2.py los ntawm SSH txhawm rau txheeb xyuas txhua yam ua haujlwm ua ntej txuas tom qab.

Kauj Ruam 8: Upload Code + Finish

Upload Code + Finish
Upload Code + Finish
Upload Code + Finish
Upload Code + Finish
Upload Code + Finish
Upload Code + Finish

Cov cai

Thaum kawg yog tias koj tseem tsis tau muaj, upload cov cai thiab hloov kho nws raws li koj nyiam (siv nano filename.py). Cov txiaj ntsig ntawm kev txuas rau Pi hla SSH yog tias koj tuaj yeem hloov kho cov cai yam tsis tau qhib lub moos.

Cov phiaj xwm nab nab los ntawm Kauj Ruam 2 ua cov hauv qab no:

  • light_clock_simple.py yooj yim qhia lub teev ntawm LEDs thiab ploj zuj zus thiab nqis ntawm LED sawb ntawm qee lub sijhawm
  • light_clock_pwm.py zoo ib yam li saum toj no tab sis tseem tso cai rau qhov ci ntawm LEDs kom txo qis thiab qhia txog feeb ntawm qhov sib txawv ci ci rau lub sijhawm. Koj yuav tsum tau ua si ib puag ncig nrog qib ci ci ntawm ob qho tib si yog li qhov sib txawv ntawm ob qhov pom tau

Cov no yuav tsum muab lub hauv paus ruaj khov rau kev ntxiv rau cov cai, piv txwv li koj yuav xav ntxiv lub pob kom ncua lub tswb teeb.

Txhawm rau pib qhov haujlwm thaum Pi khau raj peb yuav tsum ntxiv '@reboot nohup nab hab sej light_clock_pwm.py &' mus rau qhov kawg ntawm cov ntaub ntawv crontab uas tuaj yeem qhib los ntawm lub davhlau ya nyob twg nrog crontab -e. Rov pib dua koj Raspberry Pi txhawm rau txheeb xyuas nws ua haujlwm nrog sudo kaw -r tam sim no.

Muaj peev xwm ntxiv

Nov yog qee cov tswv yim ntawm kev ua haujlwm ntxiv uas tuaj yeem muab ntxiv

  • Ntxiv khawm khawm
  • Ntxiv hom teeb
  • Txuas mus rau IFTTT (piv txwv li lub teeb tuaj yeem qhib thaum koj lub xov tooj ceeb toom tawm/nyem thaum email tau txais)
  • Ntxiv qhov muaj peev xwm kov lub peev xwm piv txwv li ua lub moos rau hauv lub teeb kov

Koj yuav pom thaum siv PWM uas nyob rau qee lub sijhawm, tshwj xeeb tshaj yog nrog qhov ci ci, LED flickers me ntsis. Qhov no vim tias Pi siv software PWM yog li CPU cov txheej txheem tuaj yeem cuam tshuam rau lub luag haujlwm. Muaj cov txheej txheem tsawg dua khiav kev pab nrog qhov no yog li kuv tau siv pared down operating system Raspbian Lite. Kho vajtse PWM kuj tseem muaj nyob rau ntawm ob peb tus pin yog li yog flicker ua pov thawj qhov teeb meem, qhov no yuav yog qee yam los saib.

Kuv vam tias koj tau pom cov ntaub ntawv qhia no thiab xav tias yog kev tshoov siab kom siv lub tswb moos qub los yog siv cov cai ntawm koj tus kheej txoj haujlwm.

LED Strip Speed Challenge
LED Strip Speed Challenge
LED Strip Speed Challenge
LED Strip Speed Challenge

Qhov khoom plig thib ob hauv LED Strip Speed Challenge

Pom zoo: