السلام عليكم و رحمة الله و بركاته
اخى العزيز فهد ارفع الكود copy paste وليس صورة
|
هذا الكود كوبي باست
//////////////LCD pinout setting
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RC2_bit;
sbit LCD_D5 at RC4_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
//////////////LCD pinout direction
sbit LCD_RS_Direction at TRISC0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISC2_bit;
sbit LCD_D5_Direction at TRISC4_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
////////////////////////////////////////
#define LED porta.f4
#define push_button porta.f2
#define LED_dir trisa.f4
#define push_button_dir trisa.f2
#define input 1
#define output 0
#define is ==
#define pressed 0
char txt1[] = "ON";
char txt2[] = "OFF";
void interrupt ()
{
lcd_cmd(_lcd_clear);
INTCON.GIE=0;
if(INTCON.INTF){
if(push_button is pressed)LED=1;
lcd_out(2,4,"ON"); // ON
}
INTCON.INTF=0;
INTCON.GIE=1;
}
void main()
{
ANSELA=0; //disable Analog feature
ANSELB=0;
ANSELC=0;
OSCCON=0b01101000; //USING INTERNAL OSCILLATOR WITH FREQUANCY OF 4MHz
ADCON1=0x07; //disable ADC feature
INTCON.GIE=1; //Enable the Global Interrupt
INTCON.INTE=1;
push_button_dir=input;
LED_dir=output;
LED=0;
lcd_Init();
lcd_cmd(_LCD_CURSOR_OFF);
lcd_cmd(_lcd_clear);
while(1)
{
if(push_button is 1){
LED=0;
lcd_out(2,4,txt2); // OFF
delay_ms(250);
}
}
}