#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 3 // On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 2 // Popular NeoPixel ring size
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
unsigned long previousMillisA = 0; // will store last time LED was updated
const long intervalA = 1000; // interval at which to blink (milliseconds)
unsigned long previousMillisB = 0; // will store last time LED was updated
const long intervalB = 444; // interval at which to blink (milliseconds)
bool stateLEDA;
bool stateLEDB;
void setup() {
// put your setup code here, to run once:
pixels.begin();
}
void loop() {
// check to see if it's time to blink the LED; that is, if the difference
// between the current time and last time you blinked the LED is bigger than
// the interval at which you want to blink the LED.
unsigned long currentMillis = millis();
if (currentMillis - previousMillisA >= intervalA) {
// save the last time you blinked the LED
previousMillisA = currentMillis;
stateLEDA = !stateLEDA;
}
if (currentMillis - previousMillisB >= intervalB) {
// save the last time you blinked the LED
previousMillisB = currentMillis;
stateLEDB = !stateLEDB;
}
if (stateLEDA) {
pixels.setPixelColor(0, pixels.Color(0, 255, 0));
}
else {
pixels.setPixelColor(0, pixels.Color(0, 0, 0));
}
if (stateLEDB) {
pixels.setPixelColor(1, pixels.Color(0, 255, 0));
}
else {
pixels.setPixelColor(1, pixels.Color(0, 0, 0));
}
pixels.show();
}