Flashing Serial Display, bad code?

Hey guys, I have a simple counter project, it works but when the circuit is closed the display goes blank and when the circuit reopens, it counts fine but flashes almost like a strobe.

I've included my code and a pic of the display, any suggestions are welcomed,
Thxs y'all

#include "LedControl.h"

#define plate 2   // set the pin on which plate or switch is to be conneced
#define reset 3   //set pin to reset counter

LedControl lc=LedControl(12,11,10,1);
unsigned long delaytime=250;
int count;

void setup() {
  
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
  pinMode(plate,INPUT_PULLUP);
  pinMode(reset,INPUT_PULLUP);
}

void loop() 
{ 
  if( digitalRead(plate)==0)
  {
   count++;
   while(digitalRead(plate)==0);
  }
  if(digitalRead(reset)==0)
  {
  count=0;
  while(digitalRead(reset)==0);
  }
  if(count>9999)
  {
  count=0;
  }
    
  disp(count);
}

void disp(int a) 
{
  int one, ten, hundred, thousand;
  one=a%10;
  ten=(a/10)%10;
  hundred=(a/100)%10;
  thousand=(a/1000)%10;
  
    lc.setDigit(0,3,thousand,false);
    lc.setDigit(0,2,hundred,false);
    lc.setDigit(0,1,ten,false);
    lc.setDigit(0,0,one,false);
    
  lc.clearDisplay(0);
  delay(delaytime);
}

4 Digit 7 Seg LED Display.jpg

Thxs for the tips, not sure if I understand much of it, just a noob here lol. This is my very first project that someone wrote for me, and I am trying to learn from it.
Ok, I'll pop in while(digitalRead(plate)==0); and see where that gets me.
Cheers Delta,
The Nickernoob

Hi,
Do you need to use the clear command to the display at all, apart in setup?
Shouldn't each update to the display, clear and overwrite automatically.

Tom.... :slight_smile:

Hi,
Just to sort out what you are trying to do.

You have two switches.
One switch will reset a counter.
One switch will advance the counter.
Does the count increment once per switch operation, or continually count if the switch is held ON?

If one count per press, your sketch needs to look for the switch going from OFF to ON, not being ON.
I fail to see why all the while loops.

Sorry to ask but..
What is your electronics, programming, arduino, hardware experience?
If this is your first arduino project, may I suggest you shelve it for the moment and look at the examples in the arduino IDE.
Look in the LEARNING section of this forum, it will tell you how to do lots of simple things that will help you build up to reading switches and increment counters.

Tom.... :slight_smile: