Go Down

Topic: Serial display driving problems [RESOLVED] (Read 1 time) previous topic - next topic

liudr

Provide us your code in a different thread and we will help.

BulletMagnet83

Ok, thanks! I'll try to get something thrown together over the weekend. I think I know the sort of statements I need to be using, just not exactly how to use them! If I'm still stuck after going at it for a few hours I'll post a new thread in the relevant sub-forum :-))

BulletMagnet83

Hey all, just thought I'd post a little update. I've put some hours in today fiddling around with code, and I think I've pretty much cracked using the display. Taught myself how to use arrays which has made things a LOT neater, and made my plans to use the hardware serial port on the arduino completely unnecessary. I also managed to sort out a problem which made the display print nothing but crap on power-up/reset most of the time by throwing in a short delay before the program starts properly. Seems to work fine now.

Thanks for bearing with me while I've thrown ideas around, it's been very helpful just having an outlet to type it all out!  :)

Here's a short and crappy video of my progress so far:

http://www.youtube.com/watch?v=JMx2DsqG5TI

liudr

Cool! Did you use a buzzer for the sound effect?

BulletMagnet83

#14
Feb 18, 2012, 08:58 pm Last Edit: Feb 18, 2012, 10:33 pm by BulletMagnet83 Reason: 1
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:

Code: [Select]


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) {
 }
 
 
}




Go Up