Created
May 12, 2017 06:59
-
-
Save bha159/b02a5197ffd25c7a94530265b2c73731 to your computer and use it in GitHub Desktop.
Code for creating rolling out effect on 16X2 lcd used with atmega328
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include <util/delay.h> | |
#include "lcd.h" | |
#define STRING_LENGTH 27 | |
#define LCD_MAX 15 | |
void main() | |
{ | |
char array[STRING_LENGTH] = { "Namaste" }; | |
int i,j; | |
int start; | |
int end; | |
lcd_init(LCD_DISP_ON_CURSOR); | |
lcd_clrscr(); | |
while(1) | |
{ | |
for ( j = 0; j < STRING_LENGTH; j++ ) | |
{ | |
if ( j >= LCD_MAX ) | |
lcd_gotoxy( 0, 0 ); | |
else | |
lcd_gotoxy( LCD_MAX - j, 0 ); | |
start = (j <= LCD_MAX) ? 0 : (j - LCD_MAX); | |
end = (j <= LCD_MAX) ? j : (start + LCD_MAX); | |
if ( end >= STRING_LENGTH ) | |
end = STRING_LENGTH - 1; | |
for ( i = start; i <= end; i++ ) | |
lcd_putc( array[i] ); | |
_delay_ms(100); | |
} | |
lcd_clrscr(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment