LCD Screen countdown timer problem and input problem

Hi,
I am having two problem but it seems i wont be able to fix it since im quite new to programming. I’ve been looking on the internet for tips but i cant find any solution witch works.
I have a countdown timer on my LCD screen, but whenever the counter goes from 100 to 99 it prints 990, 980.
I have tried to clear my whole screen (Witch obviously doesnt work), and tried to find different solutions for like 3 hours but I still dont have any.

I also want my code to be adding +1 to a interger with a puls on one of my inputs.
But if i give a pulse of +5V to my DI6 (witch is the right port in my program) it doesn’t reconise it (i guess).
I hope anyone of you can help me with this, i would really appreciate it

#include <LiquidCrystal.h>
#include <SimpleTimer.h> 

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  int plusPin = 6;
  int minPin = 7;
  int I=0;
  int U=0;
  int T=0;

void setup() {
  pinMode(plusPin, INPUT);
  pinMode(minPin, INPUT);
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Verkeerstelling");
  
  delay(10000); 
}

void loop() 
  {
  lcd.clear();
  
  if (plusPin, HIGH) 
  {
  (I++);
  }
  if (minPin, HIGH) 
  {
  (U++);
  }
  lcd.setCursor(0,0);
  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);
  lcd.setCursor(0,1);
  lcd.print("Totaal: ");
  lcd.setCursor(8,1);
  lcd.print(T);
  lcd.setCursor(13, 1);

  int n = 0;
  for ( n = 110; n > 0; n--) 
    {
    lcd.setCursor(13, 1);
    delay(1000);
    lcd.print(n);
    }  
}

i would suggest you don't use the delay() function on your program.
The delay() function is a blocking function, which meant that whenever you are using it NOTHING else can happen. For instance you can read any inputs.
A solution would be to use the idea from the BlinkWithoutDelay sketch. You can find it on your IDE or here:

It is a simple idea. save the time ( millis() ) of an event into a variable. this way you can always compare it with the current time and see how much time has passed. If, for instance, a second as passed, then do something...
Take a look to the link above, i think you will understand it better...
:wink:

Thanks for trying to help me Boguz, but I cant get it working on that way either. it just makes my whole screen flickering and the time rushing down as if the delay is only 1ms.
I guess i am failing to put the commands in a good order/way into my code.

#include <LiquidCrystal.h>
#include <SimpleTimer.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() {
  pinMode(plusPin, INPUT);
  pinMode(minPin, INPUT);
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Verkeerstelling");
  
  delay(1000); 
}

void loop() 
  {
  lcd.clear();
  
  if (plusPin, LOW) 
  {
  (I++);
  }
  if (minPin, LOW) 
  {
  (U++);
  }
  lcd.setCursor(0,0);
  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);
  lcd.setCursor(0,1);
  lcd.print("Totaal: ");
  lcd.setCursor(8,1);
  lcd.print(T);
  lcd.setCursor(13, 1);

  int n = 0;
  for ( n = 110; n > 0; n--) 
    {
    lcd.setCursor(13, 1);
    //delay(1000);
    unsigned long currentMillis = millis();
    if(currentMillis - previousMillis > interval) {
      previousMillis = currentMillis;
    
    if (lcd.print(n));
    
}

Replace the last part with that:

  int n = 0;
  for ( n = 150; n > 0; n--) 
    {
   
    
delay(150);
  
  if(n > 99){
  lcd.setCursor(13,1);
  lcd.print(n);
    }
   
   if(n <= 99){
   lcd.setCursor(13,1);
   lcd.print("0");
   lcd.print(n);
  }  
   
    if(n <= 9){
    lcd.setCursor(13,1);
    Serial.print(n);
    lcd.print("00");
    lcd.print(n);
   
  }
 }

I have a countdown timer on my LCD screen, but whenever the counter goes from 100 to 99 it prints 990, 980.

Try something like this...

  for ( n = 110; n > 0; n--) 
    {
    lcd.setCursor(13, 1);
    delay(1000);
    lcd.print(n);
    lcd.print(" ");
    }

This will not work...

  if (plusPin, LOW)

You want something more like...

  if (digitalRead(plusPin) == LOW)

Of course you will still miss pulses until you get rid of the delays. And you probably want to increment the variable on the edge of the pulse, look for the input to change state before taking action. If the pulse is +5V then you should look for the pin to be HIGH to act on the rising edge.

Well thanks for helping me fixing that errorr though :smiley:
It worked flawlessly. Im going to look to fix the delay tomorrow and will tell whenever i got it :smiley: