Cov txheej txheem:

Programmable Ambient Light rau Sab Nraud Zaub: 4 Cov Kauj Ruam
Programmable Ambient Light rau Sab Nraud Zaub: 4 Cov Kauj Ruam

Video: Programmable Ambient Light rau Sab Nraud Zaub: 4 Cov Kauj Ruam

Video: Programmable Ambient Light rau Sab Nraud Zaub: 4 Cov Kauj Ruam
Video: EARTH 8: MARVEL PASTICHES (DC Multiverse Origins) 2024, Hlis ntuj nqeg
Anonim
Image
Image

Txoj haujlwm no pab koj teeb teeb pom kev ib puag ncig rau koj lub saib sab nrauv lossis TV tso cai rau koj tswj cov hauv qab no los ntawm kev nplij siab ntawm txhua lub cuab yeej muaj lub vev xaib thiab txuas nrog koj lub router.

  1. LED Xim
  2. Zaus ntawm ntsais muag muab DJ cov nyhuv
  3. Teeb xim sib txawv rau txhua sab ntawm cov zaub

Khoom siv

WS2801 LED Sawb - 1X

Txuas Txuas

Raspberry Pi - txhua tus qauv

Lub Hwj Huam Sab Nraud

Kauj ruam 1: Configure You Pi

Khau koj lub PI thiab qhib lub npav SPI los ntawm kev ua raws cov lus txib hauv qab no.

sudo raspi-teeb tsa

Sau koj tus password yog hais kom sai. Tam sim no mus rau "Advanced Options" thiab pab kom SPI.

Tom qab ntawd, teeb tsa kev vam khom.

sudo apt-tau hloov tshiab sudo apt-tau nruab sej-pip -y sudo pip nruab adafruit-ws2801 sudo pip nruab flask

Kauj ruam 2: Ua Kev Sib Txuas

Tam sim no, nws yog lub sijhawm los ua cov xov hlau sib txuas

Txuas koj li 5V khoom siv sab nraud + mus rau kab txaij 5V thiab txuas cov khoom siv hluav taws xob hauv av rau PI hauv av thiab txuas nws mus rau kab txaij GND.

CK thiab SI yuav txuas nrog PI's SPI interface.

CK / CI: Tus Pin 23 (SCKL)

SI / DI: Pin 19 (MOSI)

Kauj Ruam 3: Kuaj Yog tias Kev Sib Txuas Ua Haujlwm Zoo

Tom qab txhua qhov kev sib txuas tau ua, nws yog lub sijhawm los sim peb cov kab txaij.

Tsim cov ntaub ntawv nab npawb tshiab.

nano./strip-test.py

Tam sim no, paste cov cai hauv qab no hauv nws, thiab khaws cov ntawv. Hloov qhov LED_COUNT tus nqi piv txwv li 32 nrog tus lej ntawm LEDs koj muaj ntawm koj daim kab xev.

lub sij hawm ntshuam

ntshuam RPi. GPIO li GPIO ntshuam Adafruit_WS2801 ntshuam Adafruit_GPIO. SPI li SPI # teeb tsa suav cov pixels: LED_COUNT = 32 SPI_PORT = 0 SPI_DEVICE = 0 pixels = Adafruit_WS2801. WS2801Pixels (LED_COUNT, spi = SPI. SpiDev, SPI_PEV, = GPIO) def rainbow_cycle (pixels, tos = 0.005): rau j hauv thaj tsam (256): # ib lub voj voog ntawm tag nrho 256 xim hauv lub log rau kuv hauv ntau (pixels.count ()): pixels.set_pixel (kuv, lub log (((i * 256 // pixels.count ()) + j) % 256)) pixels.show () yog tos> 0: time.sleep (tos) pixels.clear () pixels.show () rainbow_cycle (pixels, tos = 0.01)

Tam sim no koj cov hlua LED yuav tsum ci nrog txhua xim. Yog tias nws tsis yog, txheeb xyuas koj cov kev sib txuas thiab xyuas kom nws ua haujlwm ua ntej mus rau kauj ruam tom ntej.

Kauj Ruam 4: Kho Cov Xim thiab Teeb Los Ntawm Lub Vev Xaib

Image
Image

Tam sim no, nws yog lub sijhawm los teeb tsa lub vev xaib kom pab peb hloov kho cov xim sawb thiab ntsais muag los ntawm ib lub cuab yeej.

Clone cov cai.

git clone

Hloov kho cov suav suav hauv qhov sib txawv LED_COUNT hauv cov ntawv "led.py".

Nyob ntawm seb koj tsau cov LEDs rau koj cov zaub, hloov kho qhov hloov pauv hauv qab no hauv "rgbStrip.py" cov ntaub ntawv. STRIP_EXTRA, STRIP_BOTTOM, STRIP_RIGHT, STRIP_TOP, STRIP_LEFT

Khiav lub raj mis neeg rau zaub mov

sej./led.py

Tam sim no, qhib qhov browser ntawm ib qho ntawm cov khoom siv txuas nrog koj lub router thiab nkag mus rau IP chaw nyob ntawm koj tus PI nrog chaw nres nkoj 1234. Piv txwv li yog tus IP ntawm koj tus Pi yog 192.168.1.120, koj yuav tsum qhib https://192.168.1.120:1234 thiab koj yuav tsum pom lub vev xaib zoo ib yam li daim duab.

Tam sim no koj tuaj yeem xaiv xim rau txhua sab ntawm koj lub monitor

Pom zoo: