Cov txheej txheem:

Infinity Daim iav Clock nrog Potentiometers: 3 Kauj Ruam
Infinity Daim iav Clock nrog Potentiometers: 3 Kauj Ruam

Video: Infinity Daim iav Clock nrog Potentiometers: 3 Kauj Ruam

Video: Infinity Daim iav Clock nrog Potentiometers: 3 Kauj Ruam
Video: 20 MOMENTS YOU WOULDN'T BELIEVE IF NOT FILMED 2024, Hlis ntuj nqeg
Anonim
Infinity Daim iav Clock nrog Potentiometers
Infinity Daim iav Clock nrog Potentiometers

Kuv tuaj hla daim iav infinity thiab kuv pom nws yog qhov txias heev. Qhov no tau tshoov kuv siab kom ua daim iav infinity, tab sis kuv xav tau nws kom muaj lub hom phiaj. Yog li, kuv txiav txim siab los ua lub iav tsom iav infinity ua haujlwm. Nov yog daim iav infinity uas tso cai rau koj hloov cov qauv, nrawm thiab xim siv potentiometers. (Nco tseg: Nov yog kuv thawj zaug ua tej yam zoo li no)

Khoom siv

Cia peb dhia mus rau qhov koj xav tau los ua qhov no!

Koj yuav xav tau…

1) 1 Arduino Uno

3) 1 daim ntawv qhia zaub mov

4) 1 Swb Hloov

5) 3 Potentiometers

6) 19V roj teeb

7) 5 meter WS2811 LED Sawb

8) Jumper Cable Hluav Taws Xob

9) Lub moos (Lub moos Kuv tau siv 12 nti Lub Sijhawm Loj Loj)

10) Daim iav Yooj Yim (Ib qho kuv siv Daim iav Daim iav)

11) Zaj Duab Xis Tsis Pub Leej Twg Paub (Qhov uas Kuv Siv Ib Daim iav)

12) Cov laug yuav xav tau qhov no nyob ntawm koj cov khoom koj muaj

Kauj ruam 1: Kev thaiv kab

Thaiv
Thaiv
Thaiv
Thaiv

Txoj hlua yog yooj yim heev

- SPST Hloov tig thiab tua LED's (A0)

- Sab laug potentiometer tswj lub teeb (A1)

- Qhov nruab nrab potentiometer tswj cov qauv (A2)

- Txoj cai potentiometer tswj qhov nrawm (A3)

Kauj ruam 2: Txoj Cai

#suav nrog

#Txhais tus lej PIN 6

#define NUM_LEDS 54

#define A0A0

#Txhais A1 A1

#Txhais A2 A2

#Txhais qhov A3 A3

// Parameter 1 = tus lej pixels hauv kab

// Parameter 2 = tus lej tus lej (feem ntau siv tau)

// Parameter 3 = pixel hom chij, ntxiv ua ke raws li xav tau:

// NEO_KHZ800 800 KHz bitstream (feem ntau NeoPixel khoom w/WS2812 LEDs)

// NEO_KHZ400 400 KHz (classic 'v1' (tsis v2) FLORA pixels, WS2811 tsav tsheb)

// NEO_GRB Pixels tau txuas rau GRB bitstream (feem ntau cov khoom NeoPixel)

// NEO_RGB Pixels tau txuas rau RGB bitstream (v1 FLORA pixels, tsis v2)

Adafruit_NeoPixel strip = Adafruit_NeoPixel (NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void teeb tsa () {

strip.begin ();

strip.show (); // Pib tag nrho cov pixels rau 'tawm'

}

void voj () {

yog (analogRead (A0)> = 512) {

yog (analogRead (A2)> = 768) {

yog (analogRead (A3)> = 768) {

rainbowCycle (80, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A3)> = 512) {

rainbowCycle (60, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A3)> = 256) {

rainbowCycle (40, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

lwm tus {

rainbowCycle (20, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

} lwm yog (analogRead (A2)> = 512) {

yog (analogRead (A1)> = 768) {

CylonBounce (random (255), random (255), random (255), 4, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A1)> = 512) {

CylonBounce (random (255), 0, 0, 4, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A1)> = 256) {

CylonBounce (0, random (255), 0, 4, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

lwm tus {

CylonBounce (0, 0, random (255), 4, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

} lwm yog (analogRead (A2)> = 256) {

yog (analogRead (A1)> = 768) {

siv r, g, b.

r = random (255);

g = random (255);

b = random (255);

meteorRain (r, g, b, 10, 20, tseeb, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A1)> = 512) {

siv r, g, b.

r = random (255);

g yog 0;.

b = 0;

meteorRain (r, g, b, 10, 20, tseeb, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A1)> = 256) {

siv r, g, b.

r = 0 hli;

g = random (255);

b = 0;

meteorRain (r, g, b, 10, 20, tseeb, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

lwm tus {

siv r, g, b.

r = 0 hli;

g yog 0;.

b = random (255);

meteorRain (r, g, b, 10, 20, tseeb, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

}

lwm {yog (analogRead (A1)> = 768) {

RunningLights (random (255), random (255), random (255), analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A1)> = 512) {

RunningLights (random (255), 1, 1, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

} lwm yog (analogRead (A1)> = 256) {

RunningLights (1, random (255), 1, analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

lwm tus {

RunningLights (1, 1, random (255), analogRead (A0), analogRead (A1), analogRead (A2), analogRead (A3));

}

}

lwm yam {

setAll (0, 0, 0);

}

}

void rainbowCycle (int SpeedDelay, int oldA0, int oldA1, int oldA2, int oldA3) {

peb *c;

uint16_t kuv, j;

rau (j = 0; j <256*5; j ++) {// 5 mus ntawm txhua xim ntawm lub log

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

rau (kuv = 0; kuv <NUM_LEDS; kuv ++) {

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

c = Log (((i * 256 / NUM_LEDS) + j) & 255);

setPixel (i, *c, *(c+1), *(c+2));

}

showStrip ();

ncua (SpeedDelay);

}

}

byte * Log (byte WheelPos) {

zoo li qub byte c [3];

yog (WheelPos <85) {

c [0] = WheelPos * 3;

c [1] = 255 - WheelPos * 3;

c [2] = 0;

} lwm yog (WheelPos <170) {

WheelPos -= 85;

c [0] = 255 - WheelPos * 3;

c [1] = 0;

c [2] = WheelPos * 3;

lwm yam {

WheelPos -= 170;

c [0] = 0;

c [1] = WheelPos * 3;

c [2] = 255 - WheelPos * 3;

}

rov c;

}

tsis muaj dab tsi CylonBounce (byte liab, byte ntsuab, byte xiav, int EyeSize, int oldA0, int oldA1, int oldA2, int oldA3) {

koj SpeedDelay;

koj ReturnDelay;

yog (analogRead (A3)> = 768) {SpeedDelay = 80; ReturnDelay = 120;}

lwm tus yog (analogRead (A3)> = 512) {SpeedDelay = 60; ReturnDelay = 100;}

lwm tus yog (analogRead (A3)> = 256) {SpeedDelay = 40; ReturnDelay = 80;}

lwm {SpeedDelay = 20; ReturnDelay = 60;}

rau (int kuv = 0; kuv <NUM_LEDS-EyeSize-2; i ++) {

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

setAll (0, 0, 0);

setPixel (kuv, liab/10, ntsuab/10, xiav/10);

rau (int j = 1; j <= EyeSize; j ++) {

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

setPixel (i+j, liab, ntsuab, xiav);

}

setPixel (i+Qhov muag+1, liab/10, ntsuab/10, xiav/10);

showStrip ();

ncua (SpeedDelay);

}

ncua (ReturnDelay);

rau (int kuv = NUM_LEDS-EyeSize-2; i> 0; i--) {

setAll (0, 0, 0);

setPixel (kuv, liab/10, ntsuab/10, xiav/10);

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

rau (int j = 1; j <= EyeSize; j ++) {

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

setPixel (i+j, liab, ntsuab, xiav);

}

setPixel (i+Qhov muag+1, liab/10, ntsuab/10, xiav/10);

showStrip ();

ncua (SpeedDelay);

}

ncua (ReturnDelay);

}

tsis muaj dab tsi RunningLights (byte liab, byte ntsuab, byte xiav, int oldA0, int oldA1, int oldA2, int oldA3) {

int Txoj hauj lwm = 0;

koj WaveDelay;

yog (analogRead (A3)> = 768) {WaveDelay = 80;}

lwm tus yog (analogRead (A3)> = 512) {WaveDelay = 60;}

lwm tus yog (analogRead (A3)> = 256) {WaveDelay = 40;}

lwm {WaveDelay = 20;}

rau (int j = 0; j

{

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

Txoj hauj lwm ++; // = 0; // Txoj hauj lwm + Tus nqi;

rau (int i = 0; i

// sine wave, 3 offset tsis ua tus zaj sawv!

// ntab theem = kev txhaum (kuv + Txoj Haujlwm) * 127 + 128;

// setPixel (kuv, qib, 0, 0);

// ntab theem = kev txhaum (kuv + Txoj Haujlwm) * 127 + 128;

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

setPixel (i, ((sin (i + Txoj Haujlwm) * 127 + 128)/255) * liab, ((sin (i + Txoj Haujlwm) * 127 + 128)/255) * ntsuab, ((sin (i + Txoj Haujlwm) * 127 + 128)/255) * xiav);

}

showStrip ();

ncua (WaveDelay);

}

}

tsis muaj dab tsi meteorRain (byte liab, byte ntsuab, byte xiav, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int oldA0, int oldA1, int oldA2, int oldA3) {

setAll (0, 0, 0);

koj SpeedDelay;

yog (analogRead (A3)> = 768) {SpeedDelay = 80;}

lwm tus yog (analogRead (A3)> = 512) {SpeedDelay = 60;}

lwm tus yog (analogRead (A3)> = 256) {SpeedDelay = 40;}

lwm {SpeedDelay = 20;}

rau (int kuv = 0; kuv <NUM_LEDS+NUM_LEDS; kuv ++) {

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

// fade qhov ci ci tag nrho LEDs ib kauj ruam

rau (int j = 0; j

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

yog ((! meteorRandomDecay) || (random (10)> 5)) {

fadeToBlack (j, meteorTrailDecay);

}

}

// kos lub hnub qub

rau (int j = 0; j <meteorSize; j ++) {

yog (oldA0! = analogRead (A0) || ((oldA1-256)> analogRead (A1)) || ((oldA1+256) analogRead (A2)) || ((oldA2+256) analogRead (A3)) | | ((oldA3+256)

tawg;

}

yog ((i-j = 0)) {

setPixel (i-j, liab, ntsuab, xiav);

}

}

showStrip ();

ncua (SpeedDelay);

}

}

void fadeToBlack (int ledNo, byte fadeValue) {

#ifdef ADAFRUIT_NEOPIXEL_H

// NeoPixel

uint32_t qubColor;

uint8_t r, g, b;

tus nqi;

oldColor = strip.getPixelColor (ledNo);

r = (oldColor & 0x00ff0000UL) >> 16;

g = (oldColor & 0x0000ff00UL) >> 8;

b = (oldColor & 0x000000ffUL);

r = (r <= 10)? 0: (int) r- (r*fadeValue/256);

g = (g <= 10)? 0: (int) g- (g*fadeValue/256);

b = (b <= 10)? 0: (int) b- (b*fadeValue/256);

strip.setPixelColor (coj tsis muaj, r, g, b);

#ib

#ifndef ADAFRUIT_NEOPIXEL_H

// FastLED

leds [ledNo].fadeToBlackBy (fadeValue);

#ib

}

// *** REPLACE TO HERE ***

tsis muaj dabtsis showStrip () {

#ifdef ADAFRUIT_NEOPIXEL_H

// NeoPixel

strip.show ();

#ib

#ifndef ADAFRUIT_NEOPIXEL_H

// FastLED

FastLED.show ();

#ib

}

void setPixel (int Pixel, byte liab, byte ntsuab, byte xiav) {

#ifdef ADAFRUIT_NEOPIXEL_H

// NeoPixel

strip.setPixelColor (Pixel, strip. Color (liab, ntsuab, xiav));

#ib

#ifndef ADAFRUIT_NEOPIXEL_H

// FastLED

leds [Pixel].r = liab;

leds [Pixel].g = ntsuab;

leds [Pixel].b = xiav;

#ib

}

tsis muaj dab tsi setAll (byte liab, byte ntsuab, byte xiav) {

rau (int kuv = 0; kuv <NUM_LEDS; kuv ++) {

setPixel (kuv, liab, ntsuab, xiav);

}

showStrip ();

}

Kauj Ruam 3: Tsim Lub Sijhawm

Tsim lub moos
Tsim lub moos
Tsim lub moos
Tsim lub moos
Tsim lub moos
Tsim lub moos

Kuv yuav pom zoo kom tau txais lub iav iav uas nyob sab hauv. Thaum kuv tau thov daim iav hloov pauv mus rau sab hauv ntawm lub moos muaj teeb meem vim cov lej hauv lub moos tawm los, daim iav tau khoov ua rau lub iav tsis pom kev zoo tshwm sim. Koj yuav tsum muaj daim iav hloov pauv tau yooj yim thiab Zaj Duab Xis Tsis Pub Leej Twg ua kom tiaj li sai tau. Yog tias koj tau txais lub moos kom ntseeg tau tias koj tuaj yeem tso LED sab hauv yam tsis muaj teeb meem.

Kauj Ruam 1: Qhib lub moos thiab tshem lub iav pem hauv ntej

Kauj Ruam 2: Muab Zaj Duab Xis Tsis Pub Leej Twg tso rau ntawm lub khob iav (Daim vis dis aus no qhia koj yuav ua li cas)

Kauj Ruam 3: Siv daim iav hloov pauv sab hauv ntawm lub moos (Tshem lub moos tes ua ntej ua qhov no)

Kauj Ruam 4: Ua lub qhov nyob hauv nruab nrab kom lub moos txhais tes rov qab los

Kauj Ruam 5: Muab cov hlua LED nyob ib puag ncig sab hauv ntawm lub moos (Kuv siv rab phom kub kub rau cov kauj ruam no)

Kauj Ruam 6: Qhib cov hlua LED thiab tso lub iav rau sab saum toj ntawm lub moos kom pom tias qhov cuam tshuam qhov iav tsis zoo nyob ntawd

Kauj Ruam 7: Thaum koj ua tiav nrog txhua yam tso lub moos ua ke thiab cia cov xov hlau hla mus rau tom qab

Kauj Ruam 8: Ua tsaug uas koj tau ua tiav txoj haujlwm thiab txhua yam yuav tsum ua haujlwm zoo

Yog tias koj muaj lus nug thov tawm tswv yim rau lawv hauv qab no (Paub tias kuv yuav tsis tuaj yeem teb tau, tab sis kuv yuav ua qhov zoo tshaj plaws)

Pom zoo: