MAX7219 LED Display
This device is a 7 segment display driver that removes the need for many lines of I/O ans interrupts as it works on an SPI serial interface. Farnell have a data sheet here. The device itself is quite expensive but you can get the whole display mounted on a PCB with eight 7 segment display on eByay for a reasonable price.
Thanks to Ross for the code contribution below.
// Functions to drive MAXIM 7219 8-digit LED driver // No interrupts, 3-wire interface // RSH V.0 started 29 January 2013 // V.3 uses the Rookie V.2 functions for GPIO and SPI 22 April 2013 //######################################################################### // 7219 only uses 3 lines - DIN (1), LOAD (12), CLK (13) // DIN takes 16 bits, shifted in on the rising edge of CLK; // these data are then loaded and decoded on the rising edge of LOAD // Low 8 bits are data, next 4 are address, high 4 are dont-care ; // First bit transmitted is MSB (Bit 15) // Digits are addressed independently (addresses 1 to 8, or lower if set) // other addresses are control registers. // MAX7219 is here initialised to use 7-segment decoding, drive 8 digits // and have brightness duty cycle at 11/32. These values are hard coded // in the init_max()function, but obviously could be made variables. // This application uses the BCD-to-7segment decoder available in the 7219, // so only the 4 LSBs of the data are used; bit 7 may be used to control // the decimal point if required. //######################################################################### // ...............Drive Lines for SPI................. // RB13 DataOut (Grey) (DIN) // RB14 Clock (White) (CLK) // RB15 Load (Purple) (LOAD) NOT a SPI function, but needed by MAX7219 dim g // global variable to hold the data to be displayed function init_port() spi_init(50000) io_pinMode(PORTB,15,OUT, WOFF) io_write(PORTB,15,LOW) // ensure the LOAD line is low endf function do_load() io_write(PORTB,15,TOGGLE) io_write(PORTB,15,TOGGLE) endf function send_data(add, value) // sends 2 bytes, then a load pulse // add and value are nibbles (except for decode value), other values are zero spi_data(add) spi_data(value) do_load endf function init_max() // set up the parameters for the 7219 // set the decode to Code B (ie translate BCD to 7-segments) for all digits send_data(9,255) // // set the display brightness (1/32 steps - odd values only) send_data(10,4) // set to quarter intensity for now // set the number of digits - value is one less than number send_data(11,7) // make sure the shutdown register is set to normal send_data(12,1) // diagnostic: turn on lamp test for a short time send_data(15,1) wait(300) send_data(15,0) endf function test_max() // displays global variable g dim d, t, x, v init_port() init_max() x = g for d = 1 to 8 // Digit addresses start at 1 v=x-(10*(x/10)) send_data(d,v) x=x/10 next endf