"Punk Vampire" och "Scary Nemo" Halloween masker (6 / 10 steg)
Steg 6: Testa lysdioderna
Här är koden som jag brukade kolla lysdioder:
Humör lampa
flyta RGB1 [3],
flyta RGB2 [3],
float INC [3].
int rött, grönt och blått;
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
void setup() {
randomSeed(analogRead(0));
RGB1 [0] = 0;
RGB1 [1] = 0;
RGB1 [2] = 0;
RGB2 [0] = random(256);
RGB2 [1] = random(256);
RGB2 [2] = random(256);
}
void loop() {
randomSeed(analogRead(0));
för (int x = 0; x < 256; x ++) {
INC [x] = (RGB1 [x] - RGB2[x]) / 256; }
för (int x = 0; x < 256; x ++) {
röd = int(RGB1[0]);
grön = int(RGB1[1]);
blå = int(RGB1[2]);
analogWrite (redPin, röd);
analogWrite (greenPin, grön);
analogWrite (bluePin, blå);
Delay(10);
RGB1 [0]-= INC [0];
RGB1 [1]-= INC [1].
RGB1 [2]-= INC [2].
}
för (int x = 0; x < 3; x ++) {
RGB2 [x] = random (556)-300;
RGB2 [x] = begränsa (RGB2 [x], 0, 255);
Delay(200);
}
}