Skip to content

Instantly share code, notes, and snippets.

@stlk
Last active January 22, 2018 14:16
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 stlk/09834766c1ea23a9191e46eb7e1edf0e to your computer and use it in GitHub Desktop.
Save stlk/09834766c1ea23a9191e46eb7e1edf0e to your computer and use it in GitHub Desktop.
my cool description
#include <Adafruit_NeoPixel.h>
#define PIN 1
#define WAIT 40
Adafruit_NeoPixel strip = Adafruit_NeoPixel(7, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(255);
}
void loop() {
rainbowCycle(WAIT);
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}
#include <Adafruit_NeoPixel.h>
#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(7, PIN, NEO_GRB + NEO_KHZ800); // definice komunikace s diodami
void setup() {
strip.begin(); // nastartuje diody
strip.setBrightness(255); // nastavi jas
for(uint16_t i=0; i< strip.numPixels(); i++) { // projde vsechny diody
strip.setPixelColor(i, 255, 255, 255); // nastavi bilou barvu
}
strip.show(); // nastavi vsechny diody najednou
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment