Yeah! For any timer project, you've gotta have the beeps and bloops. Especially if it's destined to be used for war games for that "movie prop" feel.
Here's what I've got going on code-wise at the moment:
const int SDATA = 12; //pin definitions, treating the DSP-0801 like a giant shift register
const int CLOCK = 11;
const int LATCH = 10;
int t_minutes = 0; //set up timekeeping variables, available to all functions (not used yet!)
int u_minutes = 0;
int t_seconds = 0;
int u_seconds = 0;
void setup () {
pinMode(SDATA, OUTPUT); //set those pins to output
pinMode(CLOCK, OUTPUT);
pinMode(LATCH, OUTPUT);
delay(500); //allow DSP-0801's onboard PIC to wake up before sending anything, seems to fix display bugs MOST of the time
for(int i = 0; i < 8; i++) { //send 8 blank digits to clear all registers
digitalWrite(LATCH, LOW);
shiftOut(SDATA, CLOCK, MSBFIRST, 0x0000); //send this value twice in 8-bit sections
shiftOut(SDATA, CLOCK, MSBFIRST, 0x0000);
digitalWrite(LATCH, HIGH);
}
int scrollRate = 100; //defines how fast digits will scroll
word charTable[8] = {
0x00F7, 0x8F3, 0x1536, 0x0079, 0x120F, 0x4000, 0x4000, 0x4000 }; //character table array - what we want to put on the display goes in here
for(int index = 0; index < 8; index++){
word charData = charTable[index];
digitalWrite(LATCH, LOW);
shiftOut(SDATA, CLOCK, MSBFIRST, (charData >> 8)); //send high byte
shiftOut(SDATA, CLOCK, MSBFIRST, charData); //send low byte
digitalWrite(LATCH, HIGH);
delay(scrollRate);
tone(7, 700, 10);
}
tone(7, 1400, 50);
delay(250);
}
void loop () {
int scrollRate = 100;
word charTable[8] = {
0x120F, 0x0038, 0x1500, 0x0000, 0x243F, 0x643F, 0x243F, 0x243F };
for(int index = 0; index < 8; index++){
word charData = charTable[index];
digitalWrite(LATCH, LOW);
shiftOut(SDATA, CLOCK, MSBFIRST, (charData >> 8));
shiftOut(SDATA, CLOCK, MSBFIRST, charData);
digitalWrite(LATCH, HIGH);
}
while(1) {
}
}