Initialer Commit

This commit is contained in:
2019-10-02 11:25:22 +02:00
commit a07f07ed0b
7 changed files with 234 additions and 0 deletions

54
src/main.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include <Arduino.h>
#include <SmartLeds.h>
#define PIN 13
#define NUM_PIXELS 24
#define FACTOR 1 /* Abstand zwischen den Hue-Werten der Pixel */
#define UPPER_HUE 147
#define LOWER_HUE 70
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
SmartLed leds( LED_WS2812B, NUM_PIXELS, PIN, 0, DoubleBuffer );
uint8_t hue = 70;
bool direction; /* true: up, false: down */
void showGradient() {
if (hue>=UPPER_HUE && direction)
{
direction = false;
} else {
if (hue<=LOWER_HUE && !direction)
{
direction = true;
}
}
if (direction)
{
hue++;
} else {
hue--;
}
// Use HSV to create nice gradient
for ( int i = 0; i <= NUM_PIXELS; i++ )
/*Der Modulo 255 ist trotz des Casts Absicht, da H=255 -> Pixel aus. */
leds[ i ] = Hsv{ static_cast< uint8_t >(( (hue + FACTOR * i) )%255), 255, 255 };
leds.show();
// Show is asynchronous; if we need to wait for the end of transmission,
// we can use leds.wait(); however we use double buffered mode, so we
// can start drawing right after showing.
}
void setup()
{
}
void loop()
{
showGradient();
delay( 500 );
}