From 6473e5aa5da7961e2fc263ebfed2b55778bd872c Mon Sep 17 00:00:00 2001 From: elyons Date: Thu, 21 Jun 2018 18:55:35 -0700 Subject: [PATCH] updated template to be cleaner --- Nano-template-WPC/Nano-template-WPC.ino | 56 +++++++------------------ 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/Nano-template-WPC/Nano-template-WPC.ino b/Nano-template-WPC/Nano-template-WPC.ino index dd48087..cda5775 100644 --- a/Nano-template-WPC/Nano-template-WPC.ino +++ b/Nano-template-WPC/Nano-template-WPC.ino @@ -5,15 +5,15 @@ #include -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); @@ -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(){ @@ -96,7 +93,7 @@ void checkPinStates(){ pd.adrLED2()->clear(); pd.pinState()->reset(); trigger =0; - bg_chase_on = 0; + attract_on = 0; timeLastEvent = millis(); } //end function checkPinStates @@ -104,35 +101,14 @@ void 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(); }