#include "LedControl.h"
int count=0;
int sw = 2;
LedControl lc=LedControl(5,7,6,1); 
// Pin 5->DIN, 7->CLK, 6->CS(LOAD), 1 = No.of devices

void show3digit(int num)
{
    int seg1,seg2,seg3;
    seg1 = (num%100)%10;
    seg2 = (num%100)/10;
    seg3 = num/100;
    lc.setDigit(0,0,seg1,false); 
    if (num>=10)
        lc.setDigit(0,1,seg2,false);
    if (num>=100)
        lc.setDigit(0,2,seg3,false); 
}
void setup()
{
    Serial.begin(9600);
    lc.shutdown(0,false);  
    lc.setIntensity(0,5); 
    lc.clearDisplay(0);   
    pinMode(sw,INPUT);  
}

void loop()
{
    int x = digitalRead(sw);
    if (x==0)
    {
        delay(300);
        if (x==0)
        {
          count=count+1; 
 if (count>999)
  count=0;  
        }
    }
show3digit(count);   
Serial.print("count = ");Serial.println(count); 
}

