Cov txheej txheem:

Yuav Siv Neopixel Ws2812 LED lossis LED Sawb lossis Led Ring Nrog Arduino: 4 Kauj Ruam
Yuav Siv Neopixel Ws2812 LED lossis LED Sawb lossis Led Ring Nrog Arduino: 4 Kauj Ruam

Video: Yuav Siv Neopixel Ws2812 LED lossis LED Sawb lossis Led Ring Nrog Arduino: 4 Kauj Ruam

Video: Yuav Siv Neopixel Ws2812 LED lossis LED Sawb lossis Led Ring Nrog Arduino: 4 Kauj Ruam
Video: 051 Tuabneeg Yuav Siv Tug Nplaig 2024, Hlis ntuj nqeg
Anonim
Yuav Siv Neopixel Ws2812 LED lossis LED Sawb lossis Led Ring Nrog Arduino
Yuav Siv Neopixel Ws2812 LED lossis LED Sawb lossis Led Ring Nrog Arduino

Nyob zoo cov menyuam txij li Neopixel coj Sawb tau nrov heev thiab nws tseem hu ua ws2812 coj sawb ib yam. Lawv yog cov neeg nyiam heev vim tias hauv cov kab no coj peb tuaj yeem hais qhia txhua tus thiab txhua tus coj sib cais uas txhais tau tias yog koj xav tau ob peb lub leds kom ci hauv ib qho xim, ob peb xim ntxiv & ob peb hauv qee qhov xim sib txawv ces nws tuaj yeem ua li ntawd. Txawm tias koj tuaj yeem ua rau txhua tus thiab txhua tus coj ci hauv xim twg koj xav tau tib lub sijhawm. Qhov no yog vim li cas lawv thiaj muaj koob meej.

Yog li hauv cov lus qhia no peb yuav kawm paub siv ws2812 lossis neopixel coj sawb nrog arduino li cas.

Kauj Ruam 1: Yam Koj Xav Tau

Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau
Yam Koj Xav Tau

rau cov lus qhia no koj yuav xav tau cov hauv qab no:

Arduino

Adafruit NeoPixel strips

Kev tiv thaiv 10k ohm

Breadboard (generic)

Jumperwires (generic)

Kauj ruam 2: Kev sib txuas

Kev sib txuas
Kev sib txuas
Kev sib txuas
Kev sib txuas

Txog kev sib txuas thov ua raws daim duab uas pom thiab txuas txhua yam Raws li pom qhov sib txawv.

Kauj ruam 3: Code

Code
Code

Mus rub Adafruit lub tsev qiv ntawv NeoPixel:

github.com/adafruit/Adafruit_NeoPixel

kom pib Koj tuaj yeem rub tawm cov ntawv.zip nrog lub tsev qiv ntawv, unzip nws ntawm koj lub khoos phis tawj, thiab rub cov ntsiab lus rau hauv koj phau ntawv Arduino cov tsev qiv ntawv. (Cov "tsev qiv ntawv" feem ntau yog tsim nyob rau hauv tib qho "Arduino" nplaub tshev uas koj khaws koj cov duab kos. Yog tias koj tsis muaj ib qho, tseem mus tom ntej thiab tsim nws.) Tsis tas li, rov pib dua Arduino IDE yog tias koj twb tau qhib nws lawm.

Thaum nws rov tshwm sim dua, koj yuav muaj qee qhov piv txwv piv txwv tshiab. Cia wb mus saib!

Cov ntaub ntawv> Piv txwv> Adafruit NeoPixel> yooj yim

Tus txiv neej no yuav teeb koj cov LEDs ntsuab, ib zaug.

Lossis koj tuaj yeem theej cov cai hauv qab no & sim nws ib yam.

// NeoPixel Ring yooj yim kos duab (c) 2013 Shae Erisson // tso tawm raws li GPLv3 daim ntawv tso cai kom haum rau lwm qhov ntawm AdaFruit NeoPixel lub tsev qiv ntawv

#include "Adafruit_NeoPixel.h" #ifdef _AVR_ #include "avr/power.h" #endif

// Tus pin twg ntawm Arduino txuas nrog NeoPixels? // Ntawm Trinket lossis Gemma peb hais qhia hloov qhov no rau 1 #txhais tus lej 6

// Muaj pes tsawg NeoPixels txuas rau Arduino? #define NUMPIXELS 16

// Thaum peb teeb tsa NeoPixel lub tsev qiv ntawv, peb qhia nws pes tsawg tus pixels, thiab tus pin twg siv los xa cov cim. // Nco ntsoov tias rau cov kab ntawv qub NeoPixel koj yuav xav tau hloov qhov ntsuas thib peb-saib cov strandtest // piv txwv rau cov ntaub ntawv ntau ntxiv ntawm qhov muaj peev xwm ua tau. Adafruit_NeoPixel pixels = Adafruit_NeoPixel (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int ncua sij hawm = 500; // ncua rau ib nrab thib ob

void teeb () {// Qhov no yog rau Trinket 5V 16MHz, koj tuaj yeem tshem tawm peb kab no yog tias koj tsis siv Trinket #if tau hais tseg (_AVR_ATtiny85_) yog (F_CPU == 16000000) clock_prescale_set (clock_div_1); #endif // End of trinket code tshwj xeeb

pixels.begin (); // Qhov no pib ua lub tsev qiv ntawv NeoPixel. }

void voj () {

// Rau txheej txheej NeoPixels thawj NeoPixel yog 0, thib ob yog 1, txhua txoj kev mus txog rau suav cov pixels rho tawm ib qho.

rau (int i = 0; i

// pixels. Color siv RGB qhov tseem ceeb, los ntawm 0, 0, 0 txog 255, 255, 255 pixels.setPixelColor (i, pixels. Color (0, 150, 0)); // Nruab nrab qaim xim ntsuab.

pixels.show (); // Qhov no xa qhov hloov tshiab pixel xim rau kho vajtse.

ncua (ncua sij hawm); // Ncua sijhawm rau lub sijhawm (hauv milliseconds).

} }

Kauj Ruam 4: Ua Kom Nws Pom

Ua Nws Teeb
Ua Nws Teeb

Tom qab xa cov cai koj neopixel coj sawb yuav zoo ib yam li kuv thiab koj tseem tuaj yeem hloov pauv cov cai saum toj no kom pom nws txawv xim thiab koj tuaj yeem sim lwm qhov piv txwv los ntawm cov tsev qiv ntawv neopixel saum toj no thiab muaj kev lom zem nrog koj neopixel coj sawb.

Pom zoo: