Last active
December 23, 2017 14:48
-
-
Save gaborbarna/9f8abc5e87544c99e5eb77ab3c56b23e 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> | |
#ifdef __AVR__ | |
#include <avr/power.h> | |
#endif | |
#define PIN 8 | |
#define NUM_LEDS 240 | |
#define BRIGHTNESS 100 | |
#define PI 3.1415926535897932384626433832795 | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800); | |
byte sines[NUM_LEDS]; | |
void setup() { | |
strip.setBrightness(BRIGHTNESS); | |
strip.begin(); | |
strip.show(); | |
for (uint16_t i = 0; i < strip.numPixels(); i++) { | |
byte val = (byte) (((sin(((float) i / NUM_LEDS * 4) * 2 * PI) + 1) / 2) * 255); | |
sines[i] = (val < 3) ? 3 : val; | |
} | |
} | |
void loop() { | |
for (uint16_t i = 0; i < strip.numPixels(); i++) { | |
for (uint16_t j = 0; j < strip.numPixels(); j++) { | |
strip.setPixelColor(j, strip.Color(sines[(j + i) % 240], 0, 0, 255) ); | |
} | |
delay(40); | |
strip.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment