Created
September 5, 2019 10:55
-
-
Save sui77/27c59c38541ae3732fac84afd5171ed2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define PIN D6 | |
#define NUMPIXELS 16 | |
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); | |
/** | |
* Werte von 0..360 auf 0..65k mappen | |
*/ | |
uint16_t degree2uint16(int degree) { | |
return degree * 65536/360; | |
} | |
void setup() { | |
Serial.begin(9600); | |
pixels.begin(); | |
} | |
void loop() { | |
for (unsigned int degree = 0; degree < 360; degree++) { | |
uint16_t adafruitHueValue = degree2uint16( degree); | |
Serial.print(degree); | |
Serial.print("° = "); | |
Serial.println(adafruitHueValue); | |
uint32_t color = pixels.ColorHSV( adafruitHueValue ); | |
for (int i=0; i < NUMPIXELS; i++) { | |
pixels.setPixelColor( i, color ); | |
} | |
pixels.show(); | |
delay(80); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment