Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #define PIN 6
- #define NUMLEDS 60
- #define BRIGHTNESS 25 // 0-255 max brightness 'number of steps'
- #define COLOR 255, 0, 175 // rgb value
- #define DELAY 75 // in milliseconds between 'steps'
- // Parameter 1 = number of pixels in strip
- // Parameter 2 = Arduino pin number (most are valid)
- // Parameter 3 = pixel type flags, add together as needed:
- // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
- // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
- // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
- // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMLEDS, PIN, NEO_GRB + NEO_KHZ800);
- boolean flag;
- void setup() {
- // put your setup code here, to run once:
- strip.begin();
- strip.show(); // Initialize all pixels to 'off'
- strip.setBrightness(BRIGHTNESS);
- strip.fill(strip.Color(COLOR), 0, NUMLEDS);
- }
- void loop() {
- strip.fill(strip.Color(COLOR), 0, NUMLEDS);
- if (flag){
- brighten();
- }
- else{
- darken();
- }
- if (strip.getBrightness() == 0 || strip.getBrightness() >= BRIGHTNESS)
- flag = !flag;
- strip.show();
- delay(DELAY); // adjust time between brightness steps
- }
- // brighten strip
- void brighten() {
- strip.setBrightness(strip.getBrightness() + 1);
- }
- // darken strip
- void darken() {
- strip.setBrightness(strip.getBrightness() - 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement