0% found this document useful (0 votes)
42 views2 pages

#Include #Include : For ( ) (// Endless Loop, Sama Saja "While (1) " Tampilan ) )

This document contains code for an Arduino program that displays scrolling text on an LCD screen. It includes header files for LCD and delay functions. It defines a character buffer containing the text to display. The main function initializes the LCD, calls a function to set registers, and enters a loop that continuously calls the display routine. The display routine clears the LCD, displays a title, then uses for loops to shift the text left one position at a time and delay before repeating.

Uploaded by

Gitok Grove
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

#Include #Include : For ( ) (// Endless Loop, Sama Saja "While (1) " Tampilan ) )

This document contains code for an Arduino program that displays scrolling text on an LCD screen. It includes header files for LCD and delay functions. It defines a character buffer containing the text to display. The main function initializes the LCD, calls a function to set registers, and enters a loop that continuously calls the display routine. The display routine clears the LCD, displays a title, then uses for loops to shift the text left one position at a time and delay before repeating.

Uploaded by

Gitok Grove
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <mega16.

h>

#include <alcd.h>
#include <delay.h>
#include <string.h>

char buffer_lcd[]="KATA BERGESER "


" KATA BERGESER KE KIRI "
"POLITEKNIK KESELAMATAN TRANSPORTASI JALAN"; //space required
// belakang sendiri kasih karakter "spasi"/0x20 biar keliatan fadingnya.

char lcd_number = 16; //diganti sesuai kebutuhan misal pake yg 4x20


//lcd_number = 20

void sett_regs(void);
void tampilan(void);
// Declare your global variables here

..
void main(void)
{
// Declare your local variables here

// LCD module initialization


lcd_init(16);
sett_regs();
lcd_init(16);
_lcd_ready();
lcd_clear();

for(;;)
{ // Endless loop, sama saja "while(1)"
tampilan();
}
}

// Setting register

void sett_regs(void){
//Define I/O
DDRA = 0xff;PORTA = 0x00;
DDRB = 0x00;PORTB = 0x00;
DDRC = 0x00;PORTC = 0x00;
}

// Display routine :D
void tampilan(void)
{

unsigned int i,j,k;


unsigned int data_len = strlen(buffer_lcd);
_lcd_ready();
lcd_clear();
lcd_gotoxy(0,0);
lcd_putsf(" TEXT BERGESER ");
for (i=lcd_number; i>=0; i++)
{
if (i > lcd_number)break;
lcd_gotoxy(i,1);
for (j=0; j<(lcd_number-i); j++){
lcd_putchar(buffer_lcd[j]);
}
delay_ms(10); //ubah untuk kecepatan pergeseran text
};

k=0;
for (i=0; i<=data_len; i++)
{
k++;
lcd_gotoxy(0,1);
for (j=0; j<16; j++){
if (buffer_lcd[j+k] == NULL){
return;
}
lcd_putchar(buffer_lcd[j+k]);
}
delay_ms(10); //ubah untuk kecepatan pergeseran text (samakan sama yang
diatas)
};
}

You might also like