Switch interface with PIC 16F877A using CCS complier 
include
"C:\Users\M.sathis kumar\Documents\CCS C Projects\robot.h"
#define
LCD_DATA_PORT getenv("SFR:PORTD")  
   #define LCD_ENABLE_PIN  PIN_E0                                    ////
    #define LCD_RS_PIN      PIN_E1  
                                 ////
    #define LCD_RW_PIN      PIN_E2                                    ////
    #define LCD_DATA4       PIN_D4                                    ////
    #define LCD_DATA5       PIN_D5                                    ////
    #define LCD_DATA6       PIN_D6                                    ////
    #define LCD_DATA7       PIN_D7        
#include
<LCD.C>
#BYTE PORTB
=0X06
#BYTE TRISB =
0X86
#BYTE PORTC
=0X07
#BYTE TRISC
=0x87
int8 X1=0;
void main()
{
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   // TODO: USER CODE!!
X1=PORTC; 
X1 &=0X10;
delay_ms(50);
trisc=0xff;//
TRISA bit (= 1) will make the corresponding PORTA pin an input
lcd_init();
TRISB = 0X00;//
Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output
while(1)
if( X1 == 0x00) 
{ 
    PORTB=0X55;
    delay_ms(1000);
   }
else 
{ 
   PORTB=0XAA;
    delay_ms(1000);
  }
}

0 comments:
Post a Comment