Cov txheej txheem:

RGB LED Teeb: 3 Kauj Ruam
RGB LED Teeb: 3 Kauj Ruam

Video: RGB LED Teeb: 3 Kauj Ruam

Video: RGB LED Teeb: 3 Kauj Ruam
Video: 3w rgb moving head laser light 2024, Kaum ib hlis
Anonim
Image
Image

Nov yog lub teeb tshwj xeeb uas pab koj pw tsaug zog zoo. Kuv siv RGB LED los ua lub teeb no, nws zoo nkauj yog tias koj ntxiv lub hau npog.

Khoom siv

1 x Arduino Leonardo

5x cev

4x kab xev

1 x RGB LED

1x Ntawv

1 x 100 ohm resistor

Kauj ruam 1: Code

Code
Code
Code
Code

Qhov txuas rau cov lej tag nrho: Arduino CC

// RGB LED teeb

// Cov xim ntawm LED hloov pauv qhov xim liab, txiv kab ntxwv, daj, ntsuab, xiav, xiav tsaus, thiab tom qab ntawd liab doog. // RGB LED yog tswj los ntawm xim liab, ntsuab, thiab xiav // Pin 7 tswj qhov ci ntawm liab // Pin 6 tswj qhov ci ntawm ntsuab // Pin 5 tswj lub teeb ci ntawm qhov teeb meem xiav () {// muab koj cov cai teeb tsa ntawm no, kom khiav ib zaug:} lub voj void () {// Cov cai loj analogWrite (7, 255); // 改 analogWrite (6, 0); // 改 analogWrite (5, 0); // 改 ncua (1000); // tos ob peb milliseconds // Liab analogWrite (7, 255); // 改 analogWrite (6, 120); // 改 analogWrite (5, 0); // 改 ncua (1000); // tos ob peb milliseconds // Txiv kab ntxwv analogWrite (7, 255); // 改 analogWrite (6, 255); // 改 analogWrite (5, 0); // 改 ncua (1000); // tos ob peb milliseconds // Yellow analogWrite (7, 0); // 改 analogWrite (6, 255); // 改 analogWrite (5, 0); // 改 ncua (1000); // tos ob peb milliseconds // Green analogWrite (7, 0); // 改 analogWrite (6, 255); // 改 analogWrite (5, 255); // 改 ncua (1000); // tos ob peb milliseconds // Blue analogWrite (7, 0); // 改 analogWrite (6, 0); // 改 analogWrite (5, 255); // 改 ncua (1000); // tos ob peb milliseconds // Dark Blue analogWrite (7, 130); // 改 analogWrite (6, 0); // 改 analogWrite (5, 255); // 改 ncua (1000); // tos ob peb milliseconds // Ntshav}

Kauj ruam 2: Piav qhia

Piav qhia
Piav qhia
Piav qhia
Piav qhia
Piav qhia
Piav qhia

RGB LED raug tswj los ntawm qhov tsis zoo ib yam thiab peb hom teeb pom kev: Liab, Ntsuab, thiab Xiav. Peb xim no yog thawj xim ntawm lub teeb. Qhov sib txawv ci ntsa iab rau txhua xim ua ke tuaj yeem ua rau txhua yam xim. Kuv xaiv cov xim ntawm zaj sawv: liab, txiv kab ntxwv, daj, ntsuab, xiav, tsaus xiav, thiab violet los ua xim ntawm kuv lub teeb.

Kauj Ruam 3: Txhim Kho Arduino

Txhim Kho Arduino
Txhim Kho Arduino
Txhim Kho Arduino
Txhim Kho Arduino

Txhim kho lub Circuit Court zoo li daim duab saum toj no.

  1. Peb lub xov hlau txuas los ntawm D5, D6, thiab D7 mus rau RGB LED.
  2. Ib txoj hlua txuas los ntawm GND mus rau LED qhov tsis zoo polarity
  3. 4 cov xov hlau txuas rau RGB LED
  4. Rub cov lej los ntawm Arduino app
  5. Ua ib daim ntawv ntxoov ntxoo npog rau nws

Nov yog qhov txuas rau yuav siv daim ntawv los ua lub npog npog li cas:

www.youtube.com/watch?v=DCelEdIow2c

Tom qab txhua qhov ntawd, koj ua tiav!

Nrog koj zoo siab!

Source: LED ntsais

Pom zoo: