Cov txheej txheem:
- Kauj Ruam 1: Cov Khoom Uas Xav Tau thiab Cov Khoom Siv
- Kauj Ruam 2: Teeb tsa Pi Ib puag ncig
- Kauj Ruam 3: Tau Txais Koj Li Pi Teeb (Ntu 1)
- Kauj Ruam 4: Tau Txais Koj Li Pi Teeb (Ntu 2)
- Kauj Ruam 5: Sau Txoj Cai
- Kauj Ruam 6: Tsim Circuit Court
- Kauj Ruam 7: Buttering Your Bread… Pawg Thawj Coj
- Kauj Ruam 8: Xeem
- Kauj Ruam 9: Hu Rau Kuv Yog Koj Muaj Lus Nug/Lus Teb
Video: Lub Vev Xaib/WiFi Tswj LED Sawb Nrog Raspberry Pi: 9 Cov Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Tom qab:
Kuv yog ib tug tub ntxhais hluas, thiab tau tsim thiab tsim cov phiaj xwm hluav taws xob me me rau ob peb xyoos dhau los, nrog rau kev koom nrog hauv kev sib tw neeg hlau.
Kuv nyuam qhuav ua haujlwm hloov kho kuv lub rooj teeb, thiab kuv txiav txim siab tias qhov zoo ntxiv yuav yog qee qhov teeb pom kev zoo. Thaum xub thawj, kuv nyuam qhuav yuav 5v lub roj teeb uas siv hluav taws xob LED sawb tswj los ntawm cov chaw taws teeb, tab sis nws tsis yog qhov ua tiav tiav thiab kuv muaj lub tswv yim. Kuv muaj ob peb seem seem nyob ib puag ncig, thiab tau sim xav txog qee yam ua nrog Raspberry Pi Kuv tau txais rau Christmas. Hauv ib hnub tshwj xeeb tshaj plaws hauv chav kawm tshawb fawb, kuv paub tias kuv tuaj yeem siv Raspberry Pi's GPIO pins los tswj lub teeb ci LED, tsuav yog kuv muaj lawv tso tawm RGB qhov tseem ceeb.
Kuv thawj qhov kev npaj tsim yog kom muaj lub teeb tswj los ntawm lub vijtsam kov tau teeb tsa ntawm kuv phab ntsa lossis rooj, tab sis tom qab qee qhov kev hloov kho kuv txiav txim siab txoj hauv kev yooj yim tshaj plaws yog yuav tswj nws nrog lwm lub cuab yeej. Thaum kuv txiav txim siab sau ib qho app rau kuv lub xov tooj hauv Java, lub vev xaib me me zoo li muaj txiaj ntsig ntau dua.
Txoj haujlwm no tau qhib rau ntau yam kev txhim kho, thiab thaum kuv cov html + php yog cov sketchy, lawv ua tiav txoj haujlwm
Xai:
Cov ntsiab lus tseem ceeb uas phau ntawv qhia no yuav ntaus yog ---
- Tswj GPIO ntawm Raspberry Pi
- Hosting Apache web server ntawm Pi
- Siv lub web server los tswj RGB LED lub teeb ci
Kauj Ruam 1: Cov Khoom Uas Xav Tau thiab Cov Khoom Siv
- 1 x Raspberry Pi (Kuv siv Pi 2 Model B)
- MicroSD daim npav
- Ib yam dab tsi los txhawb koj li Pi (USB cable thiab AC lub zog hloov pauv)
- 1 x USB WiFi adapter LOSSIS Kev Txuas Ethernet
- 1 x USB rau Serial Cable -
- 1 x GPIO tshem tawm -
- 1 x daim ntawv me me -
- USB rau MicroSD -
- Ntau Yam Xim ntawm cov tub ntxhais hlau
- Ib qho thaiv
- 3 x NPN hom transistors (Kuv siv BC547b transistors)
- 1x5V LED lub teeb sawb
- Poj niam rau Txiv neej jumper xov hlau -
Kauj Ruam 2: Teeb tsa Pi Ib puag ncig
Kuv siv lub thawv yas slanted los kaw qhov haujlwm yog li nws yuav tsis sawv ntawm kuv lub txee. Kuv drilled ib lub qhov nyob rau sab rau tus xov tooj USB txuas, thiab muab Pi nyob ib sab ntawm lub khob cij thiab Pi Wedge.
Kauj Ruam 3: Tau Txais Koj Li Pi Teeb (Ntu 1)
Txog qhov haujlwm no kuv siv qhov hloov tshiab kawg uas tsis yog desktop Raspbian
Phau ntawv qhia yuav ua li cas rau nruab Raspbian tuaj yeem pom ntawm no:
(Koj yuav xav tau USB rau microSD adapter rau koj lub khoos phis tawj)
Thaum Raspbian tau teeb tsa rau hauv daim npav SD, koj tuaj yeem txuas mus txuas rau hauv Raspberry Pi, thiab txuas Ethernet cable lossis USB WiFi adapter rau Pi
Tom ntej no, teeb tsa Tera Term rau koj lub khoos phis tawj, uas tso cai rau koj los cuam tshuam nrog Raspberry Pi lub davhlau ya nyob twg los ntawm koj lub PC:
Tom qab ntawd, ntsaws rau hauv USB kab ntawv txuas los ntawm Pi wedge rau hauv PC. Nws tuaj yeem nkag mus tau los ntawm Tera Term. Nco ntsoov tias tus naj npawb chaw nres nkoj baud tus nqi tau teeb tsa rau 115200.
Ua ntej, Pi yuav tshaj tawm sai kom nkag mus yog tias OS tau teeb tsa raug
Tus username thiab password tsis raug yog:
Username: pib
Lo lus zais: raspberry
Kauj Ruam 4: Tau Txais Koj Li Pi Teeb (Ntu 2)
Teeb WiFi
Hauv lub davhlau ya nyob twg, khiav cov lus txib
sudo nano/etc/network/interfaces
Tom qab ntawd, muab tshuaj txhuam rau hauv tus lej no thiab hloov SSID thiab PSK nrog koj lub npe router thiab tus password
auto hlo
iface lo inet loopback iface eth0 inet dhcp tso cai-hotplug wlan0 pib wlan0 iface wlan0 inet dhcp wpa-ssid "ssid" wpa-psk "password"
Cov ntaub ntawv no cia Pi txuas rau koj li WiFi
Tom ntej no, rov pib Pi nrog kab
sudo rov pib dua
Txhim kho Web Server
Nkag mus, thiab tom qab ntawd teeb tsa Apache server nrog
sudo apt -tau nruab apache2 -y
thiab
sudo apt-tau nruab php libapache2-mod-php -y
Txhawm rau nrhiav koj tus IP chaw nyob IP khiav cov lus txib
hostname -Ib
Siv koj qhov kev nkag mus saib tus IP uas tau qhia hauv kev txhawm rau txheeb xyuas yog tias nws ua haujlwm.
Piv txwv li, hauv Google Chrome Kuv yuav ntaus 192.168.1.72 rau hauv qhov chaw nyob bar.
Cov ntaub ntawv koj yuav tsum ua raws tuaj yeem nrhiav tau ntawm
Lub tsev qiv ntawv PiGPIO kuj tseem yuav tsum tau teeb tsa, uas tso cai rau koj los tswj cov ntaub ntawv raug xa hla GPIO pins.
sudo apt-tau nruab tsim-qhov tseem ceeb unzip wget
thiab
wget https://abyz.me.uk/rpi/pigpio/pigpio.zip && unzip pigpio.zip && cd PIGPIO && sudo teeb tsa
Kauj Ruam 5: Sau Txoj Cai
Nkag mus rau/var/www/html nrog kab
cd/var/www/html
Hauv cov npe, yuav muaj cov ntaub ntawv html tsis raug, uas koj yuav tsum tau kho.
sudo nano index.html
Hauv Nano, rho tawm ib yam dab tsi uas twb muaj lawm thiab hloov nws nrog cov cai hauv qab no.
(Tera Lub Sijhawm tuaj yeem yog qhov txaus luag me me nrog kev luam thiab muab tshuaj txhuam, tab sis feem ntau ib zaug koj tau theej cov ntawv, alt+v yuav tsum ua txoj haujlwm)
muaj nuj nqi readRGB (xim) {yog (color.length == 0) {document.getElementById ("txtHint"). innerHTML = ""; rov qab; } lwm {var xmlhttp = tshiab XMLHttpRequest (); xmlhttp.onreadystatechange = function () {if (this.readyState == 4 && this.status == 400) {document.getElementById ("txtHint"). innerHTML = this.responseText; }}; temp = encodeURIComponent (xim); xmlhttp.open ("TAU", "action_page.php? q =" + temp, tseeb); xmlhttp.send (); }} Xaiv Ib Xim:
Tom qab ntawd khaws nws ua lub ntsiab.html, tsis txhob siv index.html
Cov cai saum toj no ua raws li lub pob koj nias, thiab raws li cov cai uas xa cov xim koj xaiv rau lwm cov ntawv.
Tom ntej no, khiav cov lus txib
sudo nano ua
thiab muab tshuaj txhuam rau hauv
$ r $ g $ b ;
exec ("npua p 17 $ g"); exec ("npua p 22 $ r"); exec ("npua p 22 $ b"); ?>
thiab txuag nws ua action_page.php
Txoj cai no tau txais tus nqi RGB, thiab teeb tsa PWM qhov tseem ceeb ntawm LED sawb.
Kauj Ruam 6: Tsim Circuit Court
Tam sim no tias txhua qhov software tau teeb tsa, nws yog lub sijhawm los ua haujlwm ntawm kho vajtse.
Lub hom phiaj ntawm Circuit yog xa PWM (Pulse Width Modulated) cov cim los ntawm Pi mus rau LED array.
Cov hlua LED muaj plaub tus pin: liab, ntsuab, xiav, thiab lub zog (5 volts hauv kuv qhov teeb meem).
Txhua tus PWM tus pin tswj ib qho ntawm peb xim los ntawm transistor, uas ua raws li kev hloov pauv.
Txhua tus transistor muaj peb tus pin: tus sau, lub hauv paus, thiab tus xa tawm.
PWM teeb liab tswj lub voj voog ua haujlwm (ntev npaum li cas hloov thiab qhib).
Lub voj voog ua haujlwm ua rau lub teeb tsaus dua lossis ci dua.
Vim tias lub teeb hloov thiab tawm nrawm heev, tib neeg pom nws ua lub teeb pom kev sib txawv.
NCO TSEG: Hauv qhov txheej txheem, cov cim LED sawv cev rau LED teeb thiab qhov txwv tam sim no hauv cov hlau.
Kauj Ruam 7: Buttering Your Bread… Pawg Thawj Coj
Thaum ua kev sib txuas, nco ntsoov kom Pi tshem tawm.
Muab Pi tus pas nrig nrog ib kab ntawm tus pin rau ntawm ib nrab ntawm lub khob cij, thiab txuas nws mus rau Pi nrog cov hlua kab. Kuv tau siv cov xov hlau tseem ceeb los txo qhov kev sib tsoo ntawm lub khob cij, thiab kom paub tseeb tias tsis muaj dab tsi yuav raug ntsaws.
Muab cov transistors tso rau ib nrab sab saud ntawm daim ntawv qhia zaub mov (kab A), thiab txuas cov kab teeb LED ntawm ib nrab (kab H, I, lossis J).
Txuas txoj kab hluav taws xob tsis zoo mus rau GND tus pin ntawm lub npoo, thiab txoj kev tsheb nqaj hlau zoo rau 5V tus pin.
Txuas txoj kab hluav taws xob zoo mus rau LED teeb lub zog fais fab tus pin.
Rau txhua tus transistor, txuas tus pin emitter mus rau txoj kab hluav taws xob tsis zoo thiab txuas tus pin tus pin los cais kab sib luag sib xws rau LED kab pins (Kuv siv kab 1 li 5v, thiab 2, 3, thiab 4 li ntsuab, liab, thiab xiav, hauv kab lus f). Tom qab ntawd, txuas plaub tus txiv neej rau poj niam jumper xov hlau los ntawm lub khob cij rau LED sawb.
Thaum kawg, txuas lub ntsuab transistor lub hauv paus tus pin rau tus pin 17 ntawm tus npoo, liab transistor puag rau tus pin 22, thiab xiav transistor puag rau tus pin 24.
Kauj Ruam 8: Xeem
Hauv lub vev xaib, mus rau Pi's IP chaw nyob, thiab tom qab nws sau /main.html
Xaiv cov xim, thiab xav tsis thoob los ntawm "qhov xav tsis thoob ntawm thev naus laus zis niaj hnub no"!
Kauj Ruam 9: Hu Rau Kuv Yog Koj Muaj Lus Nug/Lus Teb
Yog tias koj muaj lus nug lossis lus pom zoo tso tawm lus lossis DM kuv ntawm no thiab kuv yuav sim teb sai li sai tau.
Hmoov zoo!
Pom zoo:
$ 10 Lub Vev Xaib Lub Vev Xaib Kho: 5 Kauj Ruam (nrog Duab)
$ 10 Lub Vev Xaib Lub Vev Xaib Tsis Zoo: Zoo, kuv tau ua nws dua. Kuv tau tawg kuv qhov screen. Rau cov ntawm koj uas yuav nco tau, kuv tau ua qhov no tsuas yog ib xyoos dhau los thiab xav tau kev txhim kho ib ntus kom coj kuv mus txog thaum kuv tuaj yeem hloov pauv cov muab kev pabcuam thiab tau txais xov tooj tshiab. Nws tau ua haujlwm zoo, nws tau kav rau
ESP8266 RGB LED Sawb WIFI Tswj - NODEMCU Raws li IR Chaw Taws Teeb rau Led Sawb Tswj Hauv Wifi - RGB LED Sawb Smartphone Tswj: 4 Cov Kauj Ruam
ESP8266 RGB LED Sawb WIFI Tswj | NODEMCU Raws li IR Chaw Taws Teeb rau Led Sawb Tswj Hauv Wifi | RGB LED Sawb Smartphone Tswj: Nyob zoo cov neeg hauv qhov kev qhia no peb yuav kawm paub siv nodemcu lossis esp8266 li IR chaw taws teeb los tswj RGB LED sawb thiab Nodemcu yuav raug tswj los ntawm smartphone dhau wifi. Yog li hauv paus koj tuaj yeem tswj RGB LED Sawb nrog koj lub xov tooj
Lub Vev Xaib Tswj Lub Vev Xaib Box: 4 Kauj Ruam
Lub Vev Xaib Tswj Lub Vev Xaib Box: Qhov no yog lub thawv xauv uas tuaj yeem qhib tau los ntawm kev qhia sai ntawm lub vev xaib. Qhov no txhais tau tias, koj tuaj yeem kaw cov khoom tam sim ntawd hauv lub thawv thiab tsuas yog nkag mus rau lawv thaum ib tus neeg nkag mus rau kab lus muab nkag rau ntawm lub vev xaib pej xeem. Vim li cas ib tus xav tau qhov no? Nov yog ib qho ex
Txhua Yam Txog Kev Tsim Lub Vev Xaib Lub Vev Xaib: 5 Kauj Ruam
Txhua Yam Txog Kev Tsim Lub Vev Xaib Lub Vev Xaib: Lub vev xaib pub dawb no yog daim ntawv uas koj siv los npaj phiaj xwm kev tsim kho cov ntsiab lus zoo ua kom pom tseeb cov ntsiab lus lub vev xaib. Daim qauv txheej txheem no tau tsim nrog kev yooj yim siv cov khoom siv hauv Microsoft Excel txawm hais tias muaj ntau yam software sib txawv
Lub hauv paus tseem ceeb ntawm Lub Vev Xaib-raws li Lub Vev Xaib: 7 Kauj Ruam
Cov Hauv Paus Ntawm Lub Vev Xaib-raws li Lub Vev Xaib: Cov lus qhia no yuav qhia koj cov hauv paus ntawm kev tsim lub vev xaib nrog divs li cas. Vim tias cov ntxhuav siv rau kev teeb tsa yog qhov phem!: PTo kom nkag siab cov lus qhia no, koj yuav tsum paub qhov yooj yim html thiab css. Yog tias koj tsis nkag siab qee yam, xav tias dawb rau