So I have completed my IV-18 alarm clock, included is my code feel free to test and use it, if your going to use it publicly would be nice if you mentioned me Dale Howells. Anyways below is the snippet of my multiplexing code, it consists of clocking in 2 arrays, one being the order of bits for the digit segments and one for the position of each of the digits both group of bits use a switch statement giving the corresponding values for digit segments and positions, I had to add a little extra snippet for adding in a full stop segment on a digit when needed which uses another additional array, was a weird order of bits not sure what the guys at maxim were smoking that day.
void displaydigits()
{
for( int n = 0; n < 9; n++) //repeats nine times for the nine digits
{digitalWrite(load, LOW); //load is low for load each individual number
for( int i = 0; i < 7; i++) //does it seven times for seven segments
{digitalWrite(clk, LOW); //clocks data in on rising edge
switch(input[n]){ //switches between 10 digits for the corresponding number in input array
case 1:digitalWrite(din, numone*);*
- break;*
_ case 2:digitalWrite(din, numtwo*);_
_ break;_
_ case 3:digitalWrite(din, numthree);
break;
case 4: digitalWrite(din, numfour);
break;
case 5:digitalWrite(din, numfive); //clocks in 8 individual segments for corresponding numbers*
* break;
case 6:digitalWrite(din, numsix);
break;
case 7:digitalWrite(din, numseven);
break;
case 8:digitalWrite(din, numeight);
break;
case 9:digitalWrite(din, numnine);
break;
case '-':digitalWrite(din, dash);
break;
case ' ':digitalWrite(din, blank);
break;
case '':digitalWrite(din, degres*);
break;
case 'a':digitalWrite(din, lettera);
break;
case 'c':digitalWrite(din, letterc);
break;
case 'd':digitalWrite(din, letterd);
break;
case 'e':digitalWrite(din, lettere);
break;
case 'f':digitalWrite(din, letterf);
break;
case 'g':digitalWrite(din, letterg);
break;
case 'h':digitalWrite(din, letterh);
break;
case 'j':digitalWrite(din, letterj);
break;
case 'l':digitalWrite(din, letterl);
break;
case 'n':digitalWrite(din, lettern);
break;
case 'p':digitalWrite(din, letterp);
break;
case 't':digitalWrite(din, lettert);
break;
case 'u':digitalWrite(din, letteru);
break;
case 'y':digitalWrite(din, lettery);
break;
case 'm':digitalWrite(din, letterm);
break;
case 'i':digitalWrite(din, letteri);
break;
case 'r':digitalWrite(din, letterr);
break;
default: digitalWrite(din, numzero);
}*_* digitalWrite(clk, HIGH); //clocks data (rising edge)*
* }*
* for( int m = 0; m < 13; m++) // does it twelve times for nine digits, two unused digits and the decimal point segment blanked*
* {*
* digitalWrite(clk, LOW); //clocks data in on rising edge** switch(n){ //switches position for corresponding position within array*
* case 1: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* { digitalWrite(din, posone[m]);}*
* break;*
* case 2: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* {digitalWrite(din, postwo[m]);}*
* break;*
* case 3: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* {digitalWrite(din, posthree[m]);}*
* break;*
* case 4: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* { digitalWrite(din, posfour[m]);} //clocks in 12 positions from arrays for corresponding numbers*
* break;*
* case 5: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* {digitalWrite(din, posfive[m]);}*
* break;*
* case 6: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* {digitalWrite(din, possix[m]);} //clocks decimal points if used*
* break;*
* case 7: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* {digitalWrite(din, posseven[m]);}*
* break;*
* case 8: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* {digitalWrite(din, poseight[m]);}*
* break;*
* default: if( m == 1 )*
* {*
* digitalWrite(din, fullstop[n]);*
* }*
* else*
* { digitalWrite(din, posnine[m]);}*
* }** digitalWrite(clk, HIGH); //clocks data (rising edge)*
* }*
* digitalWrite(load, HIGH); //displays data in just loaded latches*
* if( n == 1)*
* {*
* delay(2); //brightens dim right digit*
* }*
* if( n < 9)*
* {*
* delay(1); //brightens dim right digit*
* }** }*
}[/quote]
I had to add in some delays at the end in order to brighten particular digits in order to give constant brightness across all bits. Though quite annoying they are all quite dim in general and I think its down to my multiplexing of the digits, as when I was first testing with individual digits and they were much much brighter, I was wondering what people would recommend in order to make my digits brighter in general.
Thanks a lot in advance,
regards,
Dale
goodcode.ino (11.9 KB)