Ok, so I have put together a 2 minute countdown timer using an Arduino Uno, Max7221, and a 4 digit 7 segment LED display (also has periods and a colon). However I can't figure out how to make the colon light up. Any suggestions?
#include <LedControl.h> //We cant do anything without importing a suitable library!
// Lets start with the pinouts to the Max72xx led driver
// *****************************************************
int DIN = 11; // Pin 1 on the Max72xx
int CLK = 13; // Pin 13 on the Max72xx
int LOADCS = 10; // Pin 12 on the Max72xx
int flashDelay = 100; // delay in MS (100=1/10th second)
int ledBrightness = 15; // range is 0-15. 0=lowest, 15 = full power
// define the LedControl instance - if I want more I can setup lc2, lc3 etc
// ************************************************************************
LedControl lc=LedControl(DIN,CLK,LOADCS,1); // DIN, CLK, Load/CS, 1 = only one chip MAX chip attached.
void setup()
{
pinMode(DIN, OUTPUT); // once only, lets make the pins outputs
pinMode(CLK, OUTPUT);
pinMode(LOADCS, OUTPUT);
// take pins out of power save mode. No updates otherwise.
for(int index=0;index<lc.getDeviceCount();index++) {
lc.shutdown(index,false);
}
lc.setIntensity(0,ledBrightness ); //set the brightness
}
void loop() // here comes the good stuff, the main loop!
{
int row = 0; //Set the starting position
int chipId = 0; //This is not strictly reqd, but if using more than one display this will be needed
// Now the minutes
for (int minutecountdown=1; minutecountdown >=0; minutecountdown--){
int y=minutecountdown;
int minuteones;
minuteones=y%10;
lc.setDigit(chipId, row+1, minuteones, false); // These two lines add the numerical hours
// And the seconds
for (int seccountdown=600; seccountdown>0; seccountdown--)
{
int v=seccountdown;
int secones;
int sectens;
secones=v/10%10;
sectens=v/100%10;
lc.setDigit(chipId, row+3, (byte) secones, false); // True in the arguments activates the dot...
lc.setDigit(chipId, row+2, (byte) sectens, false);
delay (flashDelay);
}
}
}