Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

//xxx in put ON OFF xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

#include <mega328.h>
#include <delay.h>
// Alphanumeric LCD functions
#include <alcd.h>
unsigned char dem;
unsigned int dem2;
void ht_uchar(unsigned char thamso)
{
unsigned char tram, chuc, donvi;
tram = thamso/100; donvi = thamso%10; chuc =
thamso/10%10;
lcd_putchar(tram + 48);
lcd_putchar(chuc + 48);
lcd_putchar(donvi + 48);
}
void ht_uint(unsigned int thamso)
{
unsigned char chucngan, ngan, tram, chuc, donvi;
chucngan = thamso/10000;
ngan = thamso/1000%10;
tram = thamso/100%10;
chuc = thamso/10%10;
donvi = thamso%10;
lcd_putchar(chucngan + 48);
lcd_putchar(ngan + 48);
lcd_putchar(tram + 48);
lcd_putchar(chuc + 48);
lcd_putchar(donvi + 48);
}
void main(void)
{
// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=(1<<CLKPCE);
CLKPR=(0<<CLKPCE) | (0<<CLKPS3) | (0<<CLKPS2) |
(0<<CLKPS1) | (0<<CLKPS0);
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif
lcd_init(16);
lcd_gotoxy(5,0);
lcd_putchar('A');
delay_ms(1000);
lcd_putchar('0');

delay_ms(1000);
lcd_gotoxy(0,1);
lcd_putsf("test LCD");
while (1)
{
dem++; dem2 += 50;
lcd_gotoxy(13,0);
ht_uchar(dem);
lcd_gotoxy(11,1);
ht_uint(dem2);

delay_ms(100);
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You might also like