You are on page 1of 14

Nhm tr ging K54

H ni 5 3 - 2013

Gii thiu LCD IC DS1307 KeyPad Interupt

LCD 1602

S chn

Ghp ni vi VDK

Ghp ni vi VDK

Lcd.c #define #define #define #define #define #define #define

LCD_ENABLE_PIN PIN_E0 LCD_RS_PIN PIN_E1 LCD_RW_PIN PIN_E2 LCD_DATA4 PIN_D4 LCD_DATA5 PIN_D5 LCD_DATA6 PIN_D6 LCD_DATA7 PIN_D7

I2C

T chc b nh

Cc loi ngt thng dng


#INT_EXT : ngt ngoi #INT_TIMER0 : mt tn khc ca #INT_RTCC #INT_RB : bt k thay i no trn chn B4 n B7 #INT_RC : bt k thay i no trn chn C4 n C7

#include < 16F877.h > #device PIC16F877 *=16 #use delay (clock = 20000000 ) //thm khai bo ny nu ctrnh c dng hm delay,OSC=20 Mhz #byte portb = 0x06 //to tn danh nh portb thay th a ch portB l 06h #byte portd = 0x08 //to tn danh nh portd thay th a ch portD l 08h #INT_RB Void RB_LED ( ) // hm phc v ngt { portd=portb; } void main ( ) { set_tris_b ( 0xF0 ) ; // portB = 11110000 , B4-B7 l ng vo , B0-B3 l ng ra set_tris_d ( 0x00 ) ; // portD = 00000000 , D0-D7 u l ng ra enable_interrupts ( INT_RB ) ; // cho php ngt RB enable_interrupts ( GLOBAL ) ; // cho php ngt ton cc while( true ) { //c th thm m x l y . . . } } //main

You might also like