#include
#ifdef __AVR__
#include
#endif
uint32_t prevTime;
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN4 10 //data pin of pixel strip
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 12
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN4, NEO_GRB + NEO_KHZ800);
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = LED_BUILTIN; // the number of the LED pin
int buttonState = 0; // variable for reading the pushbutton status
//These are colours I use frequently
uint32_t c=0x000000;
uint32_t r=0xFF0000;
uint32_t g=0x00FF00;
int counter = 8;
void reload(){
Serial.println("I'm Realoading");
for(int i = 0; i<=NUMPIXELS; i++){
pixels.setPixelColor(i, r);
delay(99);
pixels.show();
}
counter = 8;
delay(1300);
}
void unload(){
//pew pew!
digitalWrite(ledPin, HIGH);
Serial.print("Fire! ");
counter = counter - 1 ;
pixels.setPixelColor(counter, c);
pixels.show();
Serial.println( counter);
delay(300);
digitalWrite(ledPin, LOW);
}
void initz(){
//initialize: start out with a full clip
//I learned you cant call a function "init()"
for(int i = 0; i<=NUMPIXELS; i++){
pixels.setPixelColor(i, g);
delay(88);
pixels.show();
}
counter = 8;
}
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(PIN4,OUTPUT );
pixels.begin();
pixels.setBrightness(55);
initz();
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
unload();
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
if (counter<=0){
reload();
}
}