Design Code

This code shows a text on the display and then all the buld-in characters. The display is easy to control. The address is put on the address bus and the characters on the databus. Then a write signal clocks the data into the display.

The program code is build with the WINAVR C-compiler.

// project : atm328 - led display HDSP2111
// Version : 1.0
// Website : www,avrprojects.net
// Date Created : 26.04.2014
// Target : ATmega328P microcontroller
// Language : C WINAVR
// Hardware requirements: LED display HDSP2111, ATMEGA328 board
// Description : interfacing ATmega328 to an HDSP2111 LED display

// INCLUDES
#include <avr/io.h>
#include <stdlib.h>
#include <util/delay.h>

// used pins on port B
#define LCD_DB4 0 // PORTD.0 pin 2 -> LCD DATA4 pin 11
#define LCD_DB5 1 // PORTD.1 pin 3 -> LCD DATA5 pin 12
#define LCD_DB6 2 // PORTD.2 pin 4 -> LCD DATA6 pin 13
#define LCD_DB7 3 // PORTD.3 pin 5 -> LCD DATA7 pin 14
#define CE 3 // PB3 pin 12 -> Chip Enable


// pulse to clock the data in the display
void pulse (void)
{
_delay_us(100);
PORTB |= 1<<CE;
_delay_us(100);
PORTB |= 0<<CE;
_delay_us(100);
}

// init LCD
void LED_init(void)
{
DDRD = 0xFF; // PORTD as output
PORTD = 0x00;
DDRB = 0xFF; // PORTB as output
PORTB = 0xFF;
}

//wriet a charecter to the display
void writechar(char address, char input)
{
PORTB = address;
PORTD = input;
pulse();
}

// write text to the display
void writetxt(char *word)
{
for (char i=0;i<8;i++)
{
writechar(i, *word++);
}
}

int main(void)
{
char i = 0;
char j = 0;
LED_init();

writetxt("HDSP2111");
_delay_ms(2000);
writetxt("AMega328");
_delay_ms(2000);

while(1)
{
for (i=0;i<128;i++)
{
writechar(j,i);
_delay_ms(250);
j++;
if (j > 7)
j=0;
}
}

}

 VIDEO

an HDSP2111 led display text from avrprojects.net on Vimeo.