Trying to make a piece of my arduino code time-based -
i have arduino wifi shield, hooked pir-detector , website. supposed control lock. have gotten of work, there 1 part i'd improve on. possible me change pir detector, if there has been movement in past, say, 5 seconds, allow open (if letter correct)? way now, has have movement, otherwise it'll lock in seconds. please note i'm new arduino coding, go easy on me
while (client.available()){ int sensorvalue2 = analogread(a1); //input pir-detector serial.println(sensorvalue2); char c = client.read(); serial.write(c); if ((sensorvalue2 > 0.0) && (c == 'l')) { //if input detector on 0.0, , text received website 'l', lock open digitalwrite(5, low); } else{ digitalwrite(5, high); } }
you can use millis() function use timer withou pausing arduino. this tutorial should it.
Comments
Post a Comment