Helligkeit/Geschwindigkeit steuerbar
- Potis auf A0/A1 können Helligkeit/Geschwindigkeit steuern - README entsprechend aktualisiert - Code neu formattiert
This commit is contained in:
parent
96dae72d04
commit
6773a22498
|
@ -10,11 +10,13 @@ unsigned char offset = 0;
|
|||
void (*viz[VIZUALIZATIONS])(unsigned char);
|
||||
volatile unsigned char currentViz = 0;
|
||||
|
||||
void sineRed(unsigned char offset) {
|
||||
void sineRed(unsigned char offset)
|
||||
{
|
||||
for (unsigned char i = 0; i < NUM_LEDS; i++)
|
||||
pixels[(i + offset) % NUM_LEDS] = CRGB(128 + floor(127 * sin(2 * 3.1415926 * i / NUM_LEDS)), 0, 0);
|
||||
}
|
||||
void falloffRed(unsigned char offset) {
|
||||
void falloffRed(unsigned char offset)
|
||||
{
|
||||
for (unsigned char i = 0; i < NUM_LEDS; i++)
|
||||
pixels[i] = 0;
|
||||
pixels[offset % NUM_LEDS] = CRGB(0x0F, 0xF, 0xF);
|
||||
|
@ -35,13 +37,15 @@ void falloffRed(unsigned char offset) {
|
|||
pixels[(offset + 15) % NUM_LEDS] = CRGB(0xFF, 0x0, 0x0);
|
||||
}
|
||||
|
||||
void changeViz(void) {
|
||||
void changeViz(void)
|
||||
{
|
||||
currentViz = (currentViz + 1) % VIZUALIZATIONS;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
void setup()
|
||||
{
|
||||
FastLED.addLeds<WS2812B, DATA_PIN>(pixels, NUM_LEDS);
|
||||
FastLED.setBrightness(255);
|
||||
FastLED.setBrightness(0);
|
||||
for (int i = 0; i < NUM_LEDS; i++)
|
||||
pixels[i] = CRGB(0, 0, 0);
|
||||
FastLED.show();
|
||||
|
@ -51,9 +55,13 @@ void setup() {
|
|||
attachInterrupt(digitalPinToInterrupt(INTR_PIN), changeViz, FALLING);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
void loop()
|
||||
{
|
||||
unsigned char brightness = 16 + floor(239.0 * analogRead(A0) / 1024.0);
|
||||
unsigned int sleep = 100 + floor(900.0 * analogRead(A1) / 1024.0);
|
||||
(*viz[currentViz])(offset);
|
||||
FastLED.setBrightness(brightness);
|
||||
FastLED.show();
|
||||
delay(100);
|
||||
delay(sleep);
|
||||
offset++;
|
||||
}
|
||||
|
|
|
@ -9,12 +9,18 @@ Specs
|
|||
- Arduino UNO
|
||||
- Data Pin: 4
|
||||
- Interrupt Pin: 2
|
||||
- Helligkeit: Potentiometer auf Pin A0
|
||||
- Geschwindigkeit: Potentiometer auf Pin A1
|
||||
- LED Strip:
|
||||
- 5m lang
|
||||
- 10 Pixel/m
|
||||
- 3 RGB-LEDs/Pixel
|
||||
- WS2818B Controller
|
||||
|
||||
Die Potentiometer auf Pins A0 und A1 steuern die Helligkeit (zwischen
|
||||
1/16-tel und voll) bzw. Geschwindigkeit (zwischen 100ms und 1000ms
|
||||
zwischen den Schritten) der Animation.
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
|
|
Loading…
Reference in a new issue