#include <12F675.h>
#device ADC=10
#fuses INTRC_IO,NOWDT,NOPUT,NOPROTECT,NOCPD,NOMCLR
#use delay(clock=4000000)
#define GP0 PIN_A0
#define GP1 PIN_A1
#define GP2 PIN_A2
#define GP3 PIN_A3
#define GP4 PIN_A4
#define GP5 PIN_A5
void init()
{
set_tris_a( 0b00000010 ); // set GP1 input, all other output
//set_tris_a(0b001100); //GP0,1,4,5 output; 2,3 input
setup_comparator( NC_NC_NC_NC ); // disable comparators
setup_adc_ports( NO_ANALOGS ); // disable analog inputs
setup_adc( ADC_OFF ); // disable A2D
}
main()
{
int durum=1;
init();
//koşul oluştur
while(1)
{
if (input(GP1) && durum==1)
{
output_high( GP0 ); // turn LED on
delay_ms( 250 ); // wait 250ms
output_low( GP0 ); // turn LED off
delay_ms( 250 ); // wait 250ms
durum=0;
}
if (!input(GP1) && durum== 0) {
output_high( GP2 ); // turn LED on
delay_ms( 250 ); // wait 250ms
output_low( GP2 ); // turn LED off
delay_ms( 250 ); // wait 250ms
durum=1;
}
}
}