#include <Adafruit_NeoPixel.h>
#define LED_PIN 21 // On Trinket or Gemma, suggest changing this to 1
#define PIR_PIN 32
#define RANDOM_PIN 33
#define NUMPIXELS 8
#define BRIGHTNESS 125
int pixel = NULL;
int last_pixel = NULL;
Adafruit_NeoPixel pixels(NUMPIXELS, LED_PIN, NEO_RGBW + NEO_KHZ800);
#define DELAYVAL 200
void lotto() {
for(int i=0; i<30; i++) {
pixels.clear();
do {
pixel = random(0, NUMPIXELS);
} while (pixel == last_pixel);
Serial.println(pixel);
pixels.setPixelColor(pixel, pixels.Color(0, 0, 0, BRIGHTNESS));
pixels.show();
last_pixel = pixel;
delay(DELAYVAL);
}
}
void setup() {
Serial.begin(115200);
Serial.println("Hello Arduino\n");
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
pinMode(PIR_PIN, INPUT);
}
void loop() {
pixels.clear(); // Set all pixel colors to 'off'
// do something on PIR
if (digitalRead(PIR_PIN) == HIGH) {
lotto();
}
}