Cov txheej txheem:

LightMeUp! Lub Sij Hawm Sijhawm Hla-platformed LED Sawb Tswj: 5 Cov Kauj Ruam (nrog Duab)
LightMeUp! Lub Sij Hawm Sijhawm Hla-platformed LED Sawb Tswj: 5 Cov Kauj Ruam (nrog Duab)

Video: LightMeUp! Lub Sij Hawm Sijhawm Hla-platformed LED Sawb Tswj: 5 Cov Kauj Ruam (nrog Duab)

Video: LightMeUp! Lub Sij Hawm Sijhawm Hla-platformed LED Sawb Tswj: 5 Cov Kauj Ruam (nrog Duab)
Video: Lub Sij Hawm - TJHENNY 2024, Hlis ntuj nqeg
Anonim
LightMeUp! Realtime Hla-platformed LED Sawb Tswj
LightMeUp! Realtime Hla-platformed LED Sawb Tswj
LightMeUp! Realtime Hla-platformed LED Sawb Tswj
LightMeUp! Realtime Hla-platformed LED Sawb Tswj
LightMeUp! Realtime Hla-platformed LED Sawb Tswj
LightMeUp! Realtime Hla-platformed LED Sawb Tswj

LightMeUp! yog lub kaw lus kuv tau tsim los tswj hwm RGB LED-Sawb hauv lub sijhawm tiag tiag, thaum ua kom tus nqi qis thiab ua tau zoo.

Tus neeg rau zaub mov tau sau hauv Node.js thiab yog li hla-platformable.

Hauv kuv qhov piv txwv, Kuv siv Raspberry Pi 3B rau kev siv mus sij hawm ntev, tab sis kuv lub Windows PC rau kev ua kom pom tseeb thiab debugging.

4pin-strip yog tswj los ntawm Arduino Nano hom-board, uas ua tiav cov lus txib kom xa PWM cov cim rau peb lub transistors hloov pauv +12VDC rau hauv cov xim sib thooj ntawm kab txaij.

Lub LightMeUp! cov kab ke tseem txheeb xyuas nws tus kheej qhov kub thiab txias, ib zaug nws siab dua 60 ° C (140 ° F) nws tig rau ob 12VDC lub khoos phis tawj lub computer ua rau hauv lub thawv, txhawm rau kom txias nws tus kheej txhawm rau txhim kho kev ua haujlwm hauv Circuit.

Lwm qhov tshwj xeeb ntawm LightMeUp! yog kom pom lub raj mis Bombay-Sapphire Gin, tab sis qhov ntawd tsis yog qhov tseem ceeb ntawm Cov Lus Qhia no.

Txaus siab nyeem ntawv:)

Khoom siv

  • Arduino Nano (lossis lwm yam ATmega328 / siab dua-raws microcontroller)
  • Raspberry Pi 3 Qauv B nrog Node.js teeb tsa (lossis lwm lub computer)
  • 12V RGB 4-Pin LED sawb
  • 12V 3A Fais fab mov
  • Jumper cables (txiv neej-txiv neej yog tias koj siv lub khob cij, tau kawg)
  • Breadboard (yeem)
  • 2 12V DC lub computer kiv cua (xaiv tau)
  • 3x TIP120 Darlington Transistor w/ heatsink (4 yog tias koj xav kom suav nrog cov kiv cua txias)
  • 2 xwm txheej LEDs liab thiab ntsuab (xaiv tau)
  • 6, 7K NTC kub raws tus tiv thaiv + 6, 7K resistor (yeem)
  • USB-Mini rau USB 2.0 cov ntaub ntawv cable (rau Raspberry Pi tham nrog Arduino)
  • Sab nraud siv USB-Hub (xaiv tau, tsuas yog rau Raspberry Pi)

Kauj Ruam 1: Nkag Siab Qhov System

Nkag Siab Qhov System
Nkag Siab Qhov System

LightMeUp! yog ua raws cov txheej txheem hluav taws xob yooj yim heev.

Peb muaj qee lub khoos phis tawj (hauv qhov no yog Raspberry Pi) uas sib txuas lus ib ntus nrog peb pawg tswj hwm microcontroller. Pawg thawj coj no ua raws cov lus txib tshwj xeeb xws li "RGB (255, 255, 255)" uas yuav tig peb cov LED-Sawb dawb.

Thaum peb tau txais peb qhov txiaj ntsig rau RED, GREEN thiab BLUE tsim nyog rau peb 4pin LED-Sawb peb ua haujlwm analogWrite (tus lej, tus nqi) txhawm rau muab peb TIP120 transistor nrog PWM teeb liab.

Qhov PWM teeb liab no tso cai rau transistor hloov tus pin xim sib xws nws tus neeg khaws khoom txuas nrog rau hauv av, mus rau qib tshwj xeeb lossis ua tiav / qhib tag nrho. Yog, ntau "rau" s:)

Los ntawm kev sib xyaw peb lub transistors tso rau LED strips 'xim pins peb tuaj yeem tsim cov xim uas peb xav tau!

Tam sim no nrog kev nkag siab no, peb tuaj yeem tawm tsam qhov kev sib tw loj tshaj plaws ntawm txoj haujlwm no, websocketserver thiab nws txuas txuas mus rau peb Arduino.

Kauj Ruam 2: Sau WebSocketServer

Sau WebSocketServer
Sau WebSocketServer

Tam sim no, peb yuav tsum tsim hom tshwj xeeb ntawm cov vev xaib, uas tso cai rau peb xa cov ntaub ntawv rov qab los yam tsis muaj kev rov ua dua tshiab ib zaug txhawm rau ua tiav lub sijhawm tiag tiag LED sawb tswj.

Thov nco ntsoov, qhov kev sib tham hauv lub sijhawm tiag tiag yog qhov tsis yooj yim sua, ib txwm yuav muaj tsawg kawg ob peb lub vib nas this ntawm kev koom nrog ncua, tab sis rau tib neeg qhov muag nws yog qhov txiav txim siab tiag tiag.

Qhov no tuaj yeem ua tiav tau yooj yim los ntawm kev siv lub tsev qiv ntawv socket.io yog tias koj siv Node.js zoo li kuv tau ua. Txawm li cas los xij, koj ib txwm tuaj yeem ua raws li koj nyiam cov lus programming, tau kawg.

Peb yuav cuam tshuam nrog lub vev xaib txuas nrog uas tso cai rau peb hloov cov ntaub ntawv nkag mus zoo li cov xim twg koj xav teeb tsa LED-sawb rau, lossis cov ntaub ntawv xwm txheej zoo li "LED ON" bidirectionally tsis muaj qhov xav tau tshiab.

Lwm qhov tseem ceeb heev uas tus neeg rau zaub mov yuav tsum muaj tab sis tsis xav tau yog tus ID nkag mus yooj yim. Kuv ua raws kuv tus lej nkag los ntawm lub npe siv yooj yim thiab lo lus zais. Cov ntaub ntawv no tom qab tshaj tawm mus rau /nkag mus txoj hauv kev ntawm cov neeg rau zaub mov, uas tom qab ntawd sib piv lub npe siv rau cov npe ntawm cov neeg siv (.txt file) thiab nws lo lus zais sib xws hauv nws SHA256-encrypted daim ntawv. Koj tsis xav kom koj cov neeg nyob ze cuam tshuam nrog koj cov hlua LED thaum koj txaus siab rau koj cov dej haus uas koj nyiam tshaj plaws, puas yog?

Tam sim no los txog lub plawv ntawm tus neeg rau zaub mov, kev sib txuas lus txuas.

Koj lub server yuav tsum muaj peev xwm sib txuas lus ib ntus - hauv Node.js qhov no tuaj yeem ua tiav los ntawm kev qhib qhov chaw nres nkoj siv lub tsev qiv ntawv "serialport". Tab sis ua ntej txiav txim siab lub npe ntawm koj qhov chaw nres nkoj arduino ntawm koj lub computer hosting server. Nyob ntawm koj lub operating system, cov chaw nres nkoj yuav muaj cov npe sib txawv, a.e. ntawm Windows cov chaw nres nkoj no muaj npe "COMx" cov chaw nres nkoj, thaum nyob rau linux lawv tau lub npe "/dev/ttyUSBx", qhov x yog tus lej ntawm USB chaw nres nkoj.

Kauj Ruam 3: Tsim kom muaj Cov Txheej Txheem ntawm Cov Lus Hais Kom Ua

Tsim kom muaj Cov Txheej Txheem ntawm Cov Lus Hais Kom Ua
Tsim kom muaj Cov Txheej Txheem ntawm Cov Lus Hais Kom Ua

Hauv daim duab saum toj no, koj pom qhov tseeb Arduino IDE code lub luag haujlwm rau RGB tswj. Lub hom phiaj ntawm cov kauj ruam no yog, ua kom koj tus kheej sau tus neeg rau zaub mov thiab Arduino pawg thawj coj tham nrog ib leeg ua tiav.

Thaum koj qhib koj qhov chaw nres nkoj ua tiav, koj yuav tsum muaj peev xwm xa cov lus txib mus rau pawg thawj coj saib xyuas koj li kev xav. Piv txwv li, yog tias peb kos tus ntiv tes saum tus xaiv xim ntawm HTML webpage, tus lej RGB yuav tsum raug xa mus rau tus neeg rau zaub mov uas tom qab ntawd xa nws mus rau koj Arduino yog li nws ua cov txheej txheem teeb tsa.

Kuv siv jscolor, lawv muaj qhov ua tau zoo ntawm kev xaiv xim xim zoo, uas yog tus tswv ntawm qhov xwm txheej hu ua "onFineChange" uas cia koj cov ntaub ntawv txheej txheem los ntawm cov xim xaiv sai li sai tau nws qhov kev hloov pauv.

Pom zoo: