Timer Help
hi,´
i have timer, when button pressed activates relay time, duration regulated potenciometer.
int potpin = a1;
const int buttonpin = a2;
void setup() {
serial.begin(9600);
pinmode(ledpin, output);
pinmode(buttonpin, input);
}
void loop()
{
int buttonstate = digitalread(buttonpin);
int val = analogread(potpin);
long tempo = (val*19.550342131);
serial.print(tempo);
serial.print("tempo:");
// read value sensor
if (buttonstate==high) {
digitalwrite(ledpin, high);
delay(tempo);
digitalwrite(ledpin, low);
} else {}; // turn ledpin off
delay(500);
}
thats code, problem when press de button, arduino stops reading code while counting, can show me way keep running code, counting time?
thank you
i have timer, when button pressed activates relay time, duration regulated potenciometer.
int potpin = a1;
const int buttonpin = a2;
void setup() {
serial.begin(9600);
pinmode(ledpin, output);
pinmode(buttonpin, input);
}
void loop()
{
int buttonstate = digitalread(buttonpin);
int val = analogread(potpin);
long tempo = (val*19.550342131);
serial.print(tempo);
serial.print("tempo:");
// read value sensor
if (buttonstate==high) {
digitalwrite(ledpin, high);
delay(tempo);
digitalwrite(ledpin, low);
} else {}; // turn ledpin off
delay(500);
}
thats code, problem when press de button, arduino stops reading code while counting, can show me way keep running code, counting time?
thank you
see blink without delay example , of many tutorials on it.
Arduino Forum > Using Arduino > Project Guidance > Timer Help
arduino
Comments
Post a Comment