Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#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(); } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)