#include <jled.h>
int pushButton = 5;
int keyLed = 4;
int keyLedStop = 3;
// blink internal LED every second; 1 second on, 0.5 second off.
auto led = JLed(keyLed).Blink(200, 500).Forever();
auto ledStop = JLed(keyLedStop).Blink(200, 500).Forever();
int val;
boolean onMore =true;
long partenza=0;
long timeInit;
long timeStopGyro =5000;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
long tempo=millis();
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
val = digitalRead(pushButton);
// print out the state of the button:
//delay(1000); // delay in between reads for stability
//Serial.println(val);
if (val == HIGH){
Serial.println("acceso");
}else{
//Serial.println("Spento");
provaStanby1();
}
//timeProgressive =map((millis()-timeInit),0,timeStopGyro,intervalLed,20);
led.Update();
}
void provaStanby1(){
if (onMore) {
partenza=millis();
Serial.print("partenza --> ");Serial.println(partenza);
onMore=false;
}
if (millis()-partenza >5000){
Serial.print("termine.. --> ");Serial.println("Arrivo");
}
ledStop.Update();
}
void provaStanby(){
if (onMore) {
Serial.print("stanby");
timeInit=millis();
onMore=false;
}
if ((millis()-timeInit)>timeStopGyro) {
// Reset the Counter
onMore=true;
Serial.print("Gyro in stanby");
} else {
}
}