Cov txheej txheem:
- Kauj Ruam 1: Siv Cov Khoom Siv
- Kauj Ruam 2: Npaj Cov Txheej Txheem Ua Haujlwm
- Kauj Ruam 3: Txuas Neopixels
- Kauj Ruam 4: Pib RPi
- Kauj Ruam 5: Pi-Qhov
- Kauj Ruam 6: Tswj Teeb
- Kauj Ruam 7: Qhib Teeb nrog Browser
- Kauj Ruam 8: Tswj Lub Teeb Los Ntawm Qhov browser
- Kauj Ruam 9: Tsim Tus Qauv rau Header thiab Footer
- Kauj Ruam 10: Qee Css Ua Kom Txhua Yam Zoo Li Me Me
- Kauj Ruam 11: Ua Tsaug
Video: Ad-thaiv Neopixels: 11 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Kuv xav ua lub vev xaib yooj yim raws li nyob deb rau ib kab ntawm neopixels txuas nrog kuv Raspberry Pi xoom thiab siv nws los thaiv kev tshaj tawm ntawm kuv lub network siv Pi-Hole. Ua ntej kuv tsuas yog xav ntxiv qee qhov coj hauv kuv chav, tab sis txuas txhua yam kom txog thaum kuv paub tias kuv tsis muaj txoj hauv kev yooj yim tswj lawv. Yog li kuv txiav txim siab los tsim lub vev xaib yooj yim nrog qee qhov kev xaiv tswj hwm siv apache server Pi-qhov installer twb tau teeb tsa. Kuv tau tso cai www-cov ntaub ntawv tso cai hauv paus, uas yog kev pheej hmoo nyab xeeb, yog li koj yuav tsum ua kom lub vev xaib tsis muaj rau ntiaj teb sab nrauv. Qhov no pib feem ntau rau kuv tus kheej cov ntaub ntawv thiab dua li cas los ua kuv thawj qhov kev qhia;) Yog li kuv yuav txaus siab tiag tiag yog tias koj tuaj yeem taw qhia Yog tias qee yam tsis meej lossis yog tias kuv tsis nco ib yam dab tsi.
Kauj Ruam 1: Siv Cov Khoom Siv
-
Raspberry Pi (Kuv pib ntawm Pi 2 thiab tom qab ntawd hloov mus rau WH, gpio pins yuav txawv me ntsis tab sis txwv tsis pub txhua tus qauv zoo)
- Yog tias koj muaj RPi yam tsis tau tsim hauv wifi, wifi adapter tseem muaj txiaj ntsig ib yam.
- Optionally rooj plaub rau raspberry pi
- 2 Txiv neej-poj niam jumper xov hlau (piv txwv)
- Neopixels ws2811 (Kuv siv cov no)
- 1 10W fais fab tuag rau RPi (Lub xov tooj them lub xov tooj qub yuav ua)
- 1 ~ 50W fais fab mov rau Neopixels (Kuv siv ib qho zoo li no, tab sis tej zaum me dua ib qho yuav txaus, tab sis yog tias koj xav tau ntau lub teeb ci, koj muaj qee chav sab laug kom nthuav dav.)
- Poj niam jack txuas ntsaws (zoo li no)
Kauj Ruam 2: Npaj Cov Txheej Txheem Ua Haujlwm
Rub tawm qhov hloov tshiab Rasbian los ntawm raspberrypi.org Cov ntawv me me yog qhov zoo rau txoj haujlwm no, yog tias koj npaj yuav siv raspberry pi rau lwm yam ntxiv ib yam li koj yuav txiav txim siab txhim kho tag nrho version nrog gui. Tom qab ntawd kuv hlawv cov duab nrog Etcher. Tom qab ntawd kom paub tseeb tias nws yuav txuas nrog kuv lub network wifi kuv ntxiv wpa_supplicant.conf hauv cov npe khau raj ntawm sd card. Cov ntsiab lus ntawm cov ntawv yuav tsum zoo li no:
~~~
ctrl_interface = DIR =/var/run/wpa_supplicant GROUP = netdev update_config = 1
network = {
ssid = "SSID"
psk = "PASSWORD"
key_mgmt = WPA-PSK}
~~~
Txhawm rau pab ssh Kuv tsim cov ntawv hu ua ssh (tsis muaj kev txuas ntxiv) hauv tib cov npe. Qhov no yuav ua kom ntseeg tau tias koj tuaj yeem teeb tsa txhua qhov los ntawm lwm lub khoos phis tawj hauv koj li.
Kauj Ruam 3: Txuas Neopixels
Ua ntej kuv ntsaws lub hwj chim rau hauv tus poj niam txuas txuas thiab muab RPi rau hauv rooj plaub. Kuv ntsia hlau hauv av los ntawm cov leds (kab xiav) thiab ib tug txiv neej sab ntawm lub xov hlau jumper hauv qhov tsis zoo ntawm lub txuas txuas. Lwm qhov kawg ntawm jumper hlau kuv tau txuas rau tus pin hauv av ntawm lub gpio header, Kuv siv tus pin 6 tab sis tus pin uas koj tuaj yeem siv tau yuav nyob ntawm qhov qauv RPi koj siv.
Qhov thib ob kuv txuas nrog qhov kawg ntawm qhov txuas txuas ntawm 5v cable los ntawm leds (kab liab). Ntawm kuv coj lawv yog jumper xaim txuas ntawm ib qho av txuas ntxiv thiab cov ntaub ntawv cable (kab dawb). Kuv tsuas yog tsis quav ntsej cov kab hauv av ntxiv, nws tsis tsim nyog rau kuv teeb tsa. Ntawm cov ntaub ntawv cable kuv txuas tus txiv neej rau poj niam jumper hlau nrog tus pin gpio 12, dua tus pin tseeb koj yuav tsum siv nyob ntawm koj li RPi. Tom qab ntawd kuv ntsaws kuv lub hwj chim rau RPi thiab cov pixels. Cov leds tau teeb pom kev rau lub sijhawm luv luv, yog tias txhua yam yog txuas kom raug.
Kauj Ruam 4: Pib RPi
Tom qab muab RPi ib feeb lossis yog li txhawm rau khau raj, Kuv tau saib tus IP chaw nyob los ntawm raspberry nrog nmap. Tab sis txhua lub network scanner, cov ntaub ntawv xov xwm ntawm koj lub router lossis feem ntau yooj yim "raspberrypi.local" yuav ua. Nrog cov ntaub ntawv ntawd kuv txuas nrog RPi los ntawm ssh. Qhov neeg siv yog pi nrog tus password raspberry. Yog li ntawd yog thawj qhov kuv hloov pauv siv 'passwd' ncaj qha tom qab thawj zaug nkag mus. Yog tias koj xav nkag mus rau koj tus pi los ntawm ssh los ntawm sab nraum koj lub network, koj yuav tsum saib mus rau hauv fail2ban thiab qhov tseem ceeb pov thawj. Kuv tus kheej tsis muaj rooj plaub siv rau qhov ntawd, yog li kuv yuav tso nws nrog tus password nkaus xwb.
Qhov thib ob kuv hloov kho software siv `sudo apt hloov tshiab && sudo apt hloov tshiab -Y`. Kuv kuj xav tau qee qhov software ntxiv los suav sau cov libery `sudo apt-get install scons swig git python-dev build-essential -Y`. Tom qab ntawd kuv tau theej cov ntawv zoo los ntawm Jeremy Garff ntawm github `git clone https:// github.com/jgarff/rpi_ws281x.git`. Tom qab ntawd lub tsev qiv ntawv raug cloned Kuv tau mus rau rpi_ws281x cov npe, siv scons thiab tom qab ntawd teeb tsa lub tsev qiv ntawv nrog 'sudo python sej/setup.py install`. Hauv nab hab sej/piv txwv yog qhov zoo demo "strandtest.py" nrog cov duab zoo nkauj tiag tiag uas koj tuaj yeem pib nrog 'sudo python nab hab sej/piv txwv/strandtest.py`.
Kauj Ruam 5: Pi-Qhov
Txhawm rau tsim lub network dav ntxiv blocker, Pi-Hole yog qhov zoo tshaj plaws. Nws nruab nrog tsuas yog `sudo curl -sSL https://install.pi-hole.net | tsoo '. Qhov zoo yog tias nws yuav teeb tsa lub web server ib yam.
Tom qab khiav lub installer koj yuav xav nkag rau hauv tus thawj tswj hwm ntawm koj lub router thiab muab koj RPi tus IP-chaw nyob zoo li qub thiab teeb nws li DHCP Server. Yog tias koj tau teem sijhawm qiv qis dua koj li PI-qhov yuav tsum ua haujlwm tam sim no.
Kauj Ruam 6: Tswj Teeb
Txoj hauv kev yooj yim tshaj plaws los tswj cov neopixels yog nrog cov khoos phis tawj me. Tab sis kom siv ssh txhua lub sijhawm koj xav tig lub teeb tsis yooj yim, tshwj xeeb tshaj yog ntawm lub xov tooj ntawm tes. Yog li kuv txiav txim siab siv lub vev xaib me me li kev tswj chaw taws teeb. Nov yog Qhov Ruaj Ntseg Ruaj Ntseg, vim tias kuv tau tso cai rau www-data hauv paus yam tsis muaj kev txheeb xyuas tus password. Tej zaum koj yuav tsum tsis txhob ua qhov chaw no muaj nyob sab nraum koj li.
Txhawm rau ua kom yooj yim xaiv ntawm lub dashboard ntawm PI -qhov thiab lub teeb pom kev deb, Kuv tau muab tus neeg siv pi sau nkag mus rau/var/www/html nrog 'sudo chown -R pi/var/www.html` thiab kuv tau tsim ib qho index.php cov ntaub ntawv hauv/var/www/html/. Tej yam yooj yim xws li:
~~~
Index Pi qhov Lub teeb nyob deb
~~~
nyob zoo Tom qab ntawd kuv tsim daim nplaub tshev tshiab hu ua teeb kom muaj txhua yam los ntawm neopixels ua ke. Ntawm no kuv tsim colour.py raws li strandtest.py los ntawm libery.
~~~
los ntawm neopixel ntshuam * # Ntshuam qee lub tsev qiv ntawv
ntshuam sys
def coj (strip, xim, pib, kawg): # Tsim kom muaj nuj nqi hu rau leds
rau kuv hauv ntau (pib, xaus):
strip.setPixelColor (kuv, xim)
strip.show ()
BRIGHTNESS = int (sys.argv [4]) # Qhov ntsuas thib plaub ntawm kab hais kom ua yuav yog qhov ci. (1-255)
COUNT = 50 # Tus lej ntawm tus lej PIN = 12 # Tus pin siv ntawm RPi
FREQ_HZ = 800000 # LED teeb liab zaus hauv hertz (feem ntau yog 800khz)
DMA = 5 # DMA channel siv los tsim teeb liab (sim 5)
INVERT = Cuav # Muaj tseeb los hloov lub teeb liab (thaum siv NPN transistor qib
strip = Adafruit_NeoPixel (COUNT, PIN, FREQ_HZ, DMA, INVERT, BRIGHTNESS)
strip.begin ()
R = int (sys.argv [1]) # Tus nqi liab yog thawj qhov ntsuas
G = int (sys.argv [2]) # Tus nqi ntsuab yog tus ntsuas thib ob
B = int (sys.argv [3]) # Tus nqi xiav yog qhov ntsuas thib peb
sim:
leds (kab txaij, Xim (R, G, B), 0, 49) #Yuav pib tso cai nrog xaiv xim thiab ci ci.
tshwj tsis yog KeyboardInterrupt:
xim (strip, Xim (0, 0, 0), 0, 49)
~~~
Yog tias koj ua qhov no nrog sudo ntawm lub davhlau ya nyob twg lub teeb yuav tsum mus rau hauv cov xim tshwj xeeb. Txhawm rau muab www-cov ntaub ntawv sudo tso cai kuv ntxiv `www-data TXHUA = (TXHUA) NOPASSWD: TXHUA)` `rau sudoers cov ntaub ntawv (/etc/sudoers) ncaj qha hauv qab tus neeg siv hauv paus.
Kauj Ruam 7: Qhib Teeb nrog Browser
Tom qab ntawd kuv tsim qhov tsis sib xws.php, lub sijhawm no hauv /teeb. ~~~
< ?php $R = 100; $G = 100; $B = 100; $BRIGHTNESS = 100; exec("sudo python colour.py $R $G $B $BRIGHTNESS"); ?>
~~~
Thaum kuv tam sim no mus ntsib raspberrypi.local/teeb/index.php lub leds yuav tig dawb. Txawm hais tias qhov no yog qhov pib zoo, Kuv nyiam kom muaj tsawg kawg qee cov nyees khawm ntawm cov chaw taws teeb.
Kauj Ruam 8: Tswj Lub Teeb Los Ntawm Qhov browser
Kuv tsim qhov cuam tshuam nrog pob tw siv daim ntawv html. Kuv tsis nyiam ua tej yam uas tsis xav tau, yog li kuv tsim daim nplaub tshev hu ua qauv nrog kuv lub taub hau, kab ntawv thiab lub ntsiab php code. Kuv (tam sim no) zaum kawg /teeb /index.php zoo li no:
~~~
~~~
Txhawm rau ua cov nyees khawm ua haujlwm Kuv tau ua tus qauv BasicControl.php. Hauv qhov no kuv tau teev cov cai uas yuav tsum tau ua thaum lub pob nyem. Vim tias kuv nyiam qhov kev ua yeeb yam strandtest kuv suav nrog qhov ntawd ib yam. Qhov kev sib tw yuav txuas ntxiv mus ntev kawg, yog li kuv tau ua lwm lub pob kom nres cov txheej txheem thaum twg kuv xav tau.
~~~ <? php cov
$ Kuv = 100;
$ R = 0;
$ G = 0;
$ B = 0;
yog (isset ($ _ POST ['strandtest_start'])) {exec ("sudo python strandtest.py"); }
lwm tus yog (isset ($ _ POST ['strandtest_stop'])) {exec ("sudo pkill -9 -f strandtest.py"); }
lwm tus yog (tawm ($ _ POST ['liab'])) {$ R = 255; $ G = 0; $ B = 0; exec ("sudo python colour.py $ R $ G $ B $ I"); }
lwm yog (isset ($ _ POST ['ntsuab'])) {$ R = 0; $ G = 255; $ B = 0; exec ("sudo python colour.py $ R $ G $ B $ I"); }
lwm tus yog (tawm ($ _ POST ['xiav'])) {$ R = 0; $ G = 0; $ B = 255; exec ("sudo python colour.py $ R $ G $ B $ I"); }
lwm tus yog (tawm ($ _ POST ['dawb'])) {$ R = 255; $ G = 255; $ B = 255; exec ("sudo python colour.py $ R $ G $ B $ I"); }
lwm yog (isset ($ _ POST ['tawm']))) {shell_exec ('sudo python off.py'); }
lwm tus yog (isset ($ _ POST ['reboot'])) {shell_exec ('sudo reboot tam sim no'); }?> Ib
~~~
Kauj Ruam 9: Tsim Tus Qauv rau Header thiab Footer
Tam sim no txhua yam ua haujlwm, tab sis nws tsis zoo siab heev los saib. Tom qab ntshuam lub header thiab footer tag nrho cov ntsiab lus ntawm lub xaib muaj, tsuas yog tsis yog tus qauv.
Header.php:
~~~
Teeb
Lampjes
Kev Tswj Yooj Yim
Advanced Tswj
~~~
Thiab footer.php:
~~~
~~~
Kauj Ruam 10: Qee Css Ua Kom Txhua Yam Zoo Li Me Me
Raws li koj yuav tau pom, kuv tab tom siv cov ntawv css los tswj cov txheej txheem. Kom paub tseeb tias kuv cov chaw taws teeb siv tau ntawm cov ntxaij vab tshaus me me ib yam Kuv tau siv qee qhov css flexboxes nrog autowrap.
~~~
/ * Stylesheet rau lub teeb tswj interface *
* Siv rau txhua nplooj ntawv */
lub cev {keeb kwm yav dhau-xim: f9fcfa; font-tsev neeg: Arial; pem: 0;. }
h1 {xim: dawb; text-align: nruab nrab; }
p {font-tsev neeg: verdana; font-loj: 20px; }
h2 {}
/ * Lub taub hau */
.header {qhov siab: 10%; zaub: flex; justify-content: flex-start; align-items: chaw; siv: 0px. padding-laug: 5%; keeb kwm yav dhau:#3F51B5; align-items: chaw; }
. HeaderLinks {xim: dawb; }
.navbar {tso saib: flex; flex: 30%; justify-content: chaw nyob ib puag ncig; xim tom qab: #3F51B5; xim: dawb; }
/ * Tus footer */
.footer {keeb kwm yav dhau xim: #3F51B5; qhov siab: 10%; text-align: nruab nrab; }
/ * Index.php */
.buttons {zaub: flex; flex-kev taw qhia: kab; flex-qhwv: qhwv; justify-content: qhov chaw nruab nrab; qhov siab: 80%; cov khoom sib dhos: flex-start; }
.buttons_index {padding: 0%; ciam teb-dav: nyias; ciam teb-style: khoom; ciam teb-xim: dub; xim tom qab: #3949ab; xim: dawb; font tsev neeg: sans-serif; dav: 24%; qhov siab: 20%; }
.buttons_index: hover {padding: 0%; ciam teb-dav: nyias; ciam teb-style: khoom; ciam teb-xim: dub; xim tom qab: #536DFE; xim: dawb; font tsev neeg: sans-serif; dav: 24%; qhov siab: 20%; }
~~~
Kauj Ruam 11: Ua Tsaug
Thiab qhov ntawd yog nws. Txhua yam ua haujlwm rau kuv thiab kuv vam tias nws yuav ua haujlwm rau koj ib yam yog tias xaiv sim kuv cov lus qhia. Yog tias koj tau sim luam qee qhov chaws, kuv yuav tsum ntxiv ob peb qhov chaw rau tso nws rau ntawm no, yog li koj yuav tsum rho tawm lawv ua ntej cov cai yuav siv tau dua.
Kuv vam tias koj nyiam nyeem txhua yam. Yog tias koj muaj lus tawm tswv yim, Kuv yuav nyiam hnov nws!
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
Tsev Automation Kauj Ruam ntawm Kauj Ruam Siv Wemos D1 Mini Nrog PCB Tsim: 4 Kauj Ruam
Tsev Automation Kauj Ruam Ib Leeg Siv Wemos D1 Mini Nrog PCB Tsim: Tsev Automation Kauj Ruam los ntawm Kauj Ruam siv Wemos D1 Mini nrog PCB Tsim cov tub ntxhais kawm ntawv qib siab. Tom qab ntawd ib tus ntawm peb cov tswv cuab tuaj
RC Taug Qab Neeg Hlau Siv Arduino - Kauj Ruam Ib kauj ruam: 3 Kauj Ruam
RC Tracked Robot Siv Arduino - Kauj Ruam Ib Nrab: Hav guys, Kuv rov qab los nrog lwm tus neeg hlau txias chassis los ntawm BangGood. Vam tias koj tau dhau los ntawm peb cov phiaj xwm yav dhau los - Spinel Crux V1 - Tus Cwj Pwm Tswj Tus Neeg Hlau, Spinel Crux L2 - Arduino Xaiv thiab Muab Neeg Hlau nrog Robotic caj npab thiab Badland Braw
Kawm Yuav Ua Li Cas Kos Tus Tswm Ciab - Kauj Ruam Ib Kauj Ruam: 6 Kauj Ruam
Kawm Yuav Ua Li Cas Thiaj Li Tswmciab - Kauj Ruam Ib kauj ruam: Cov tswm ciab no siv sijhawm 10 feeb los kos yog tias koj ua raws kuv cov kauj ruam ua tib zoo
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: 9 Kauj Ruam
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: Cov ntawv qhia no yog qhia koj yuav tsim lub Caj Npab Caj Npab ntawm koj tus kheej li cas