Skip to content

Instantly share code, notes, and snippets.

@sui77
Created September 5, 2019 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sui77/27c59c38541ae3732fac84afd5171ed2 to your computer and use it in GitHub Desktop.
Save sui77/27c59c38541ae3732fac84afd5171ed2 to your computer and use it in GitHub Desktop.
#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