Home » » Hiển thị số đếm trên LCD

Hiển thị số đếm trên LCD

CODE:
===Nguồn: http://khongtenmien.com/forum/showthread.php?t=1835===
/*****************************************************
This program was produced by the
CodeWizardAVR V2.03.4 Standard
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : LCD_BUTTON
Version : V1.0
Date    : 4/11/2009
Author  : Tran_trungbmt@yahoo.com
Company :
Comments:


Chip type           : ATmega8
Program type        : Application
Clock frequency     : 8.000000 MHz
Memory model        : Small
External RAM size   : 0
Data Stack size     : 256
*****************************************************/

#include <mega8.h>
#include <delay.h>

// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x18 ;PORTB
#endasm
#include <lcd.h>

// Declare your global variables here
//unsigned char count=5;
void xuat_lcd(unsigned int data_byte)
{
    unsigned char i,temp[5];;
    for(i=0;i<5;i++)
    {
        temp[4-i]=data_byte%10;
        data_byte /=10;
    }
    lcd_gotoxy(6,1);
    for(i=0;i<5;i++)
    {
       lcd_putchar(temp[i]+48);  
    }
}
void main(void)
{
//DDRB =0xFF;
DDRD=0x0F;
DDRC =0;
TCCR1A =0;
TCCR1B =6;
lcd_init(16);
lcd_gotoxy(0,0);
lcd_clear();
lcd_putsf("GIA TRI DEM: ");
lcd_gotoxy(6,1);
lcd_putsf("00000");
while (1)
      {
      if(PIND.5==0)
      {
        xuat_lcd(TCNT1);
      }
      };
}
//======
file mô phỏng và code : http://www.zshare.net/download/584719413bbe053f/

0 nhận xét:

Đăng nhận xét

 
ĐỂ ĐƯỢC HỖ TRỢ VUI LÒNG LIÊN HỆ
Ngọc Anh
Hot Line : 090.447.5528
Email : ngocanh.songlong@gmail.com