/*
Alla pressione del pulsante si attiva o disattiva il lampeggo di un led, mentre un
altro led lampeggia indisturbato.
*/
#include "urutils.h"
int led = 13;
int led2 = 14;
byte pulsante =12;
byte precval, val;
unsigned long tbase = 50;
DiffTimer tmrdeb;
DiffTimer tmrblink1, tmrblink2;
void setup() {
Serial.begin(115200);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(pulsante, INPUT);
precval=LOW;
tmrdeb.start();
tmrblink2.start();
}
// loop principale
void loop() {
if(tmrdeb.get() > tbase){
tmrdeb.reset();
//task_toggle
val = digitalRead(pulsante);
if(precval==LOW && val==HIGH){ //rivelatore di fronte di salita
tmrblink1.toggle();
}
}
precval=val;
//task_blink1
if (tmrblink1.get() > 500) {
digitalWrite(led, !digitalRead(led));
tmrblink1.reset();
}
//task_blink2
if (tmrblink2.get() > 1000) {
digitalWrite(led2, !digitalRead(led2));
tmrblink2.reset();
}
delay(10);
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
r1:1
r1:2
led2:A
led2:C
r2:1
r2:2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
led1:A
led1:C
r3:1
r3:2