LED display hack

Hacking the sparkfun 7 segment 4 digit LED display

September 2009,

This display is intended to be sent data via logic level serial or SPI. The display's mega168 micro is powerful enough to be used for stand alone applications or as a master controller. Even when used as a slave peripheral to another micro (or PC) TWI is a very useful interface which allows devices to be individually addressable and to have buss arbitration if multiple masters try to use the TWI buss at the same time.

My aim is the hack the display to use my TWI bootloader and run software which can grab data as TWI master and display it. It particular I want to display pressure.

It would also be possible to interface pressure or other sensors directly to the display module.


The first part of the hack was to add a five volt regulator so I can power the module from a 12V power buss. Even with all LEDs lit the regulator doesn't seem to need a heatsink.


The second part of the hack is to be able to reprogram the micro via the ISP pins. I found that the existing pinout maps fairly well the six pin inline header I've used in the past. I already have an adapter made to use this header with my kanda programmer.

My 6 pin inline ISP header pinout is.

Display connector pinout is.

I wired the four pads I needed onto a six pin header and also wired the header to the MOSI and reset pad.
It works.

I did have a bit of a glitch because I was using old programming software which didn't support the 168. While tracking down the problem I managed to corrupt the clock fuses and had to melt part of the polymorph so I can attach a resonator to the clock to regain control.


Image A screw connector was polymorphed above the micro and wired directly to the TWI pins. The self heating of the micro may become a problem. I am unlikely to overheat the chip but raising the temperature will affect the RC oscillator frequency.

The third part is to sever the TWI lines which are being used to drive the display and bring them out to a connector. Two unused port lines (pb0 and pb1) were then wired to the display pins. Severing the SDA line involved hacking through the PCB to break the track were it connects to the display on the display side of the PCB.
It works.

The code.

Image A simple test pattern is the first step in writing the software to drive the display.

The above test pattern was displayed using the following timer interrupt code.
volatile unsigned char tick; // system tick counter
	switch (tick)
	case 0 : sbi(PORTC,3); outp(0x0c,PORTD); cbi(PORTC,0); tick++; break;
	case 1 : sbi(PORTC,0); outp(0xb6,PORTD); cbi(PORTC,1); tick++; break;
	case 2 : sbi(PORTC,1); outp(0x9e,PORTD); cbi(PORTC,2); tick++; break;
	case 3 : sbi(PORTC,2); outp(0xcc,PORTD); cbi(PORTC,3); tick=0; break; 
	default : tick=0; 

This isn't the purest code. If you want accurate timing a jump table might work well. Obviously the final code won't have the segment data embedded like this. Using the native bit set and clear instructions avoids messy bit fiddling and masking. This method should work well even when the common cathode controls are spread across multiple ports.

The regulator is getting a little warm during long soak tests as I'll probably add a little heat sink. The above code gives the maximum brightness dimming the display would reduce the heat build up.
I'm not sure I want to add dimming to mine. Using a second timer compare interrupt to turn the LEDs off after an adjustable interval shouldn't be too hard.

This version lights the first decimal point and L1,L2 and L3.
Image Another pattern to test the new pins for "col" and "dp".

	switch (tick)
	case 0 : sbi(PORTC,3); outp(0x0e,PORTD); cbi(PORTB,0); tick++; break;
	case 1 : sbi(PORTB,0); sbi(PORTB,1); outp(0x0c,PORTD); cbi(PORTC,0); tick++; break;
	case 2 : sbi(PORTC,0); cbi(PORTB,1); outp(0xb6,PORTD); cbi(PORTC,1); tick++; break;
	case 3 : sbi(PORTC,1); outp(0x9e,PORTD); cbi(PORTC,2); tick++; break;
	case 4 : sbi(PORTC,2); outp(0xcc,PORTD); cbi(PORTC,3); tick=0; break; 
	default : tick=0; 

Much time passes. Some success.

Image Real pressure data.

The thing basically works but I'm not sure how well it will play on a busy network.
See the comments on the TWI page.

January 2010 - Version 2.

I have use for two or three of these TWI enabled displays so I made a second one. Looking at the time taken to add the ISP and the fact that the bootstrap is already debugged - it would have been easier to program it using an adapter based on ezi-hooks or similar clips. I'll make myself one day.

Image Version two is a little different because I'm using 8 pin DIN connectors for all the devices on the TWI network.

Most of my sensor,display and controller modules use the same DIN plugs and same pin out. The sockets are 8 pin but 7 and probably 5 pin plugs will also fit them. The modules can be plugged into any socket and can be unplugged from the chamber and run on a socket near the computer for easier debugging.

Image As usual the the circuit was made bulletproof using polymorph.

The first display now has something like a month or two runtime in the five months since it was made. It is still working fine unlike some of the other modules I made (which are pro-mini based).


Created by eddie. Last Modification: Sunday 24 of January, 2010 12:16:58 AEDT by eddie.

Main Index

Switch Theme


System Administrator, 13:56 AEST, Sun 07 of Aug, 2016: upgrading to tiki 15.2
eddie, 19:31 AEST, Sat 06 of Aug, 2016: This website is now served from Brisbane - in a Binarylane cloud.
System Administrator, 16:07 AEDT, Wed 06 of Mar, 2013: More f'n spam. No more anon posting from now on.
Anonymous, 18:44 AEDT, Mon 04 of Mar, 2013: deleted
Anonymous, 08:36 AEDT, Sun 03 of Mar, 2013: Very nice site!

Last-Visited Pages

Online Users

45 online users