Display Scrolling text

In this project we make a scrolling text with the HDSP2111 display.

You can enter text of any length which will be shown on the display.

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

 

// project : atm328 - led display HDSP2111 scrolling text
// Version : 1.0
// Website : www,avrprojects.net
// Date Created : 28.04.2014
// Target : ATmega328P microcontroller
// Language : C WINAVR
// Hardware requirements: LED display HDSP2111, ATMEGA328 board
// Description : iscrolling text on 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;
}

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

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

void scrollDisplay(char *words)
{
char buffer[9];
int i = 0;
while(words[i] != 0)
{ char blank = 0;
for (int j = 0; j<8; j++)
{
if (!blank && words[i+j]== 0)
blank = 1;
if (blank == 1)
buffer[j] = ' ';
else
buffer[j] = words[i+j];
}
writetxt(buffer);
_delay_ms(200);
i++;
}
}


int main(void)
{
LED_init();

while(1)
{
{
char intro[] = " HDSP2111 LED Display - www.avrprojects.net ";
scrollDisplay(intro);
_delay_ms(500);
}
}
}

 

VIDEO

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