Cov txheej txheem:

Potentio Qhov Taw Qhia Siv RGB Neopixel: 4 Cov Kauj Ruam
Potentio Qhov Taw Qhia Siv RGB Neopixel: 4 Cov Kauj Ruam

Video: Potentio Qhov Taw Qhia Siv RGB Neopixel: 4 Cov Kauj Ruam

Video: Potentio Qhov Taw Qhia Siv RGB Neopixel: 4 Cov Kauj Ruam
Video: QHIA QHOV TSEEB - KUB VAJ LOOG TSUA NEW MUSIC VIDEO 2022 2024, Kaum ib hlis
Anonim
Potentio Qhov Taw Qhia Siv RGB Neopixel
Potentio Qhov Taw Qhia Siv RGB Neopixel

Hauv kab lus no kuv yuav ua qhov ntsuas ntsuas ntawm lub ntsuas hluav taws xob siv RGB Nano pixel ntiv nplhaib.

Yog li, pes tsawg qhov kev tawm tsam ua rau ntawm lub hwj chim ntsuas hluav taws xob yuav tshwm rau ntawm lub nplhaib RGB

Kauj Ruam 1: Cov Cheeb Tsam Xav Tau

Yuav tsum tau Cheebtsam
Yuav tsum tau Cheebtsam
Yuav tsum tau Cheebtsam
Yuav tsum tau Cheebtsam
Yuav tsum tau Cheebtsam
Yuav tsum tau Cheebtsam
Yuav tsum tau Cheebtsam
Yuav tsum tau Cheebtsam

cov khoom xav tau los ua nws:

  • Arduino Nano v.3
  • RGB RIng NeoPixels
  • Potentiometer
  • Jumper Hlau
  • USB mini tso
  • Pawg Thawj Coj

Kauj ruam 2: Circuit Schema

Schema ntawm Circuit
Schema ntawm Circuit
Schema ntawm Circuit
Schema ntawm Circuit

Sib sau ua ke tag nrho cov khoom siv raws li cov phiaj xwm rho tawm saum toj no.

Arduino rau Potensio & RGB Ring

+5V ==> 3. Potensio & VCC

GND ==> 1. Potensio & GND

A0 ==> 2. Potensio

D12 ==> IN

Kauj ruam 3: Programming

Programming
Programming

Luam cov cai hauv qab no, thiab muab nws tso rau hauv koj daim duab

#include #ifdef _AVR_ #include // Yuav tsum tau rau 16 MHz Adafruit Trinket #endif

#Txhais tus lej PIN 12

#define NUMPIXELS 16

Adafruit_NeoPixel pixels (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 10

void teeb tsa () {

#if txhais (_ AVR_ATtiny85_) && (F_CPU == 16000000)

clock_prescale_set (clock_div_1); #ib

pixels.begin ();

pixels.setBrightness (10);

Serial.begin (9600); }

void lub voj ()

{pixels.clear (); int val = analogRead (A0); val = daim ntawv qhia (val, 0, 1023, 0, 18);

yog (val == 1) {rau (int i = 0; i <1; i ++) {pixels.setPixelColor (i, pixels. Color (0, 225, 0)); ncua (10); }}

yog (val == 2)

{rau (int i = 0; i <2; i ++) {pixels.setPixelColor (i, pixels. Color (32, 225, 0)); ncua (10); }}

yog (val == 3)

{rau (int i = 0; i <3; i ++) {pixels.setPixelColor (i, pixels. Color (64, 225, 0)); ncua (10); }}

yog (val == 4)

{rau (int i = 0; i <4; i ++) {pixels.setPixelColor (i, pixels. Color (96, 225, 0)); ncua (10); }}

yog (val == 5)

{rau (int i = 0; i <5; i ++) {pixels.setPixelColor (i, pixels. Color (128, 225, 0)); ncua (10); }}

yog (val == 6)

{rau (int i = 0; i <6; i ++) {pixels.setPixelColor (i, pixels. Color (160, 225, 0)); ncua (10); }}

yog (val == 7)

{rau (int i = 0; i <7; i ++) {pixels.setPixelColor (i, pixels. Color (192, 225, 0)); ncua (10); }}

yog (val == 8)

{rau (int i = 0; i <8; i ++) {pixels.setPixelColor (i, pixels. Color (225, 225, 0)); ncua (10); }}

yog (val == 9)

{rau (int i = 0; i <9; i ++) {pixels.setPixelColor (i, pixels. Color (225, 225, 0)); ncua (10); }}

yog (val == 10)

{rau (int i = 0; i <10; i ++) {pixels.setPixelColor (i, pixels. Color (225, 192, 0)); ncua (10); }}

yog (val == 11)

{rau (int i = 0; i <11; i ++) {pixels.setPixelColor (i, pixels. Color (225, 160, 0)); ncua (10); }}

yog (val == 12)

{rau (int i = 0; i <12; i ++) {pixels.setPixelColor (i, pixels. Color (225, 128, 0)); ncua (10); }}

yog (val == 13)

{rau (int i = 0; i <13; i ++) {pixels.setPixelColor (i, pixels. Color (225, 96, 0)); ncua (10); }}

yog (val == 14)

{rau (int i = 0; i <14; i ++) {pixels.setPixelColor (i, pixels. Color (225, 64, 0)); ncua (10); }}

yog (val == 15)

{rau (int i = 0; i <15; i ++) {pixels.setPixelColor (i, pixels. Color (225, 32, 0)); ncua (10); }}

yog (val == 16)

{rau (int i = 0; i <16; i ++) {pixels.setPixelColor (i, pixels. Color (225, 0, 0))); ncua (10); }}

yog (val == 17)

{rau (int i = 0; i <17; i ++) {pixels.setPixelColor (i, pixels. Color (225, 0, 0))); ncua (10); }}

yog (val == 18)

{rau (int i = 0; i <18; i ++) {pixels.setPixelColor (i, pixels. Color (225, 0, 0))); ncua (10); }} pixels.show (); ncua (DELAYVAL); }

Sketch file tuaj yeem rub tawm hauv qab no:

Kauj Ruam 4: Qhov tshwm sim

Txog cov txiaj ntsig tuaj yeem pom hauv video saum toj no.

Yog li txhua lub sijhawm ntsuas lub zog tig, tus lej thiab xim ntawm LEDs ntawm lub nplhaib yuav ci raws li tus lej ntawm qhov ua tiav ntawm lub hwj chim.

Pom zoo: