Skip to content

Commit

Permalink
updated template to be cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
elyons committed Jun 22, 2018
1 parent ac0122d commit 6473e5a
Showing 1 changed file with 16 additions and 40 deletions.
56 changes: 16 additions & 40 deletions Nano-template-WPC/Nano-template-WPC.ino
Expand Up @@ -5,15 +5,15 @@

#include <pinduino.h>

int aLEDNum1 = 50;
int aLEDNum2 = 50;
int aLEDNum1 = 50; // Number of LEDs in LED strip 1
int aLEDNum2 = 50; // Number of LEDs in LED strip 2

pinduino pd (aLEDNum1, aLEDNum2, "Nano");

int bg_chase_on = 0;
int attract_on = 1;
unsigned long timeLastEvent = 0; // time last event was last triggered
int startChaseWaitTime = 20000; //Amount of time to wait before chase lights start up again 1000 == 1 second
int whiteWaitTime = 1000; //Amount of time to wait before gumball goes to white
int attractWaitTime = 20000; //Amount of time to wait before chase lights start up again 1000 == 1 second
String color = "white"; // color of LEDs that attract mode starts with

void setup() {
Serial.begin(115200);
Expand All @@ -23,15 +23,12 @@ void setup() {
}

void loop(){
for (int i = 0; i < 500; i = i + 1) { //check pinstates for a while
pd.pinState()->update();
}
pd.pinState()->update();
// Print the pin states out to serial
// pd.pinState()->print();
checkPinStates();
if (millis()-timeLastEvent > startChaseWaitTime) { bg_chase_on=1; }
if (millis()-timeLastEvent > whiteWaitTime) { pd.adrLED1()->fadeIn("white", 200);}
if (bg_chase_on){backgroundChase();}
if (millis()-timeLastEvent > attractWaitTime) { attract_on=1; }
if (attract_on){attractMode();}
}

void checkPinStates(){
Expand Down Expand Up @@ -96,43 +93,22 @@ void checkPinStates(){
pd.adrLED2()->clear();
pd.pinState()->reset();
trigger =0;
bg_chase_on = 0;
attract_on = 0;
timeLastEvent = millis();
}
//end function checkPinStates
}



void backgroundChase() {
pd.adrLED1()->clear();
pd.adrLED1()->color("white",255);
pd.adrLED2()->color("white",255);
for (int i = 0; i < 20000; i = i + 1) { //check pinstates for a while
pd.pinState()->update();
void attractMode() {
pd.adrLED1()->sparkle(color,1);
pd.adrLED2()->sparkle(color,1);
if (random(1000) == 0) {
if (color == "white") color = "blue";
else if (color == "blue") color = "red";
else color = "white";
}
pd.adrLED1()->fadeOut(1000);
pd.pinState()->update();
delay(500);
pd.pinState()->update();
pd.adrLED1()->fadeIn("blue",500);
pd.pinState()->update();
pd.adrLED1()->fadeColor2Color("blue","purple",500);
pd.pinState()->update();
pd.adrLED1()->fadeColor2Color("purple","red",500);
pd.pinState()->update();
pd.adrLED1()->fadeColor2Color("red","orange",500);
pd.pinState()->update();
pd.adrLED1()->fadeColor2Color("orange","yellow",500);
pd.pinState()->update();
pd.adrLED1()->fadeColor2Color("yellow","green",500);
pd.pinState()->update();
pd.adrLED1()->fadeColor2Color("green","blue",500);
pd.pinState()->update();
pd.adrLED1()->fadeOut(500);
pd.pinState()->update();
delay(500);
pd.pinState()->update();
}


0 comments on commit 6473e5a

Please sign in to comment.