Created
December 11, 2017 03:33
-
-
Save benrules2/ff6dcecf8d6088e0c73fb3900a8ed39e to your computer and use it in GitHub Desktop.
Arduino Fireplace Code
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
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson | |
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library | |
#include <Adafruit_NeoPixel.h> | |
#ifdef __AVR__ | |
#include <avr/power.h> | |
#endif | |
// Which pin on the Arduino is connected to the NeoPixels? | |
// On a Trinket or Gemma we suggest changing this to 1 | |
#define PIN 6 | |
// How many NeoPixels are attached to the Arduino? | |
#define NUMPIXELS 8 | |
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. | |
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest | |
// example for more information on possible values. | |
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); | |
void setup() { | |
pixels.begin(); // This initializes the NeoPixel library. | |
} | |
void loop() { | |
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. | |
int count = NUMPIXELS; | |
for(int i=0;i< NUMPIXELS;i++){ | |
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 | |
int flicker= random(1, 15); | |
int r = 255 - flicker * 2; | |
int g = 63 - flicker; | |
int b = flicker / 2; | |
pixels.setPixelColor(i, pixels.Color(r, g, b)); | |
pixels.show(); // This sends the updated pixel color to the hardware. | |
} | |
delay(random(30,50)); // Delay for a period of time (in milliseconds). | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment