Hi, im making a countdown timer with a max 7219 4 digit 7 segment display and arduino Uno. I want to add thousandths of a second to the 8 second timer. I am unsure on how to add more digits, i know I need to change the countdown from intervals of 1000ms to 1ms but thats all I know, if someone could help that would be great! Thanks!
Code:
#include "LedControl.h"
const int buttonPin = 2;
int buttonState = 0;
LedControl lc=LedControl(12,11,10,1);
/* we always wait a bit between updates of the display */
unsigned long delaytime=1000;
void setup() {
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(2, INPUT);
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
}
void CountDown() {
digitalWrite(5, HIGH);
for(int i=8;i>0;i--) {
lc.setDigit(0,0,i,false);
delay(delaytime);
}
lc.clearDisplay(0);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
delay(delaytime);
}
void loop() {
buttonState = digitalRead(2);
if (buttonState == HIGH){
digitalWrite(6, LOW);
CountDown();
}
}