Professional Documents
Culture Documents
Hướng dẫn bài tập tuần 6
Hướng dẫn bài tập tuần 6
H ni 5 3 - 2013
LCD 1602
S chn
Ghp ni vi VDK
Ghp ni vi VDK
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
#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