Hello everybody, i have been trying to get my timer working correctly without the usage of a delay function.
Is someone albe to find a solution for me to get it working without the delay function?
I have been trying many different things but havent found a solution yet..
#include <LiquidCrystal.h>
#include <SimpleTimer.h>
#include <TimerOne.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int plusPin = 6;
int minPin = 7;
int I=0;
int U=0;
int T=0;
long previousMillis = 0;
long interval = 1000;
void setup() {
Serial.begin(9600);
pinMode(plusPin, INPUT); //Declare PINS
pinMode(minPin, INPUT);
lcd.begin(16, 2); //Declare LCD
lcd.setCursor(0,0); //Declare Cursor
lcd.print("Verkeerstelling"); //Print tekst
delay(10000);
}
void loop()
{
I=0;
U=0;
T=0;
lcd.clear(); //Clear LCD
if (digitalRead(plusPin) == HIGH) //Set pin as formule
{
(I++);
}
if (digitalRead(minPin)== HIGH)
{
(U++);
}
lcd.setCursor(0,0); //Printing In: (I) and Uit: (U)
lcd.print("In: ");
lcd.setCursor(4,0);
lcd.print(I);
lcd.setCursor(8,0);
lcd.print("Uit: ");
lcd.setCursor(13,0);
lcd.print(U);
T = (I-U); //Sum of I - U making total of T
lcd.setCursor(0,1); //Printing Totaal: (T)
lcd.print("Totaal: ");
lcd.setCursor(8,1);
lcd.print(T);
lcd.setCursor(13, 1);
int n = 300; //Set countdowntimer
for ( n = 300; n > 0; n--) //Looping countdowntimer
{
delay(1000);
lcd.setCursor(13, 1);
lcd.print(n); //Print timer
lcd.print(" ");
}
}