# define LEDA 2 # define LEDB 3 # define POT A0 int ledStateA = LOW; int ledStateB = LOW; long pMillisA = 0; long pMillisB = 0; long pausa = 0; void setup() { pinMode (POT, INPUT); pinMode(LEDA, OUTPUT); pinMode(LEDB, OUTPUT); } void loop(){ pausa = analogRead(POT); unsigned long cMillisA = millis(); if( cMillisA - pMillisA > (pausa + 50)) { pMillisA = cMillisA; if ( ledStateA== LOW) ledStateA = HIGH; else ledStateA = LOW; digitalWrite(LEDA, ledStateA);} unsigned long cMillisB = millis(); if( cMillisB - pMillisB > ( pausa + 275) ) { pMillisB = cMillisB; if ( ledStateB == LOW) ledStateB = HIGH; else ledStateB = LOW; digitalWrite(LEDB, ledStateB);} }
lunedì 1 dicembre 2014
Blink regolabile
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento