Hi Guys..
I'm new to PIC's micro-controller
but i have written this code, but i want RC1 and RC2 to output digital signals..
I'm new to PIC's micro-controller
but i have written this code, but i want RC1 and RC2 to output digital signals..
Rich (BB code):
#include <htc.h>
__CONFIG(MCLREN & UNPROTECT & BORDIS & WDTDIS & PWRTEN & INTIO);
// let RA1 be the signal from the first switch and RA2 be the signal from the second switch.
int up_1 = 0; // flag to signal when the door is open due to switch one open
int up_2 = 0; // flag to signal when the door is open due to switch two open
int main(){
TRISC = 0b00000000;
TRISA = 0b11111111;
while (1){
if((RA1 == 1) && (RA2 == 0)){
RC1 = 1; //Sets The RC1 to digital output 1
RC2 = 0; //Sets The RC2 to digital output 0
up_1 = 1;
//delay();
}
if((RA1 == 0) && (RA2 == 1)){
RC1 = 1; //Sets The RC1 to digital output 1
RC2 = 0; //Sets The RC2 to digital output 0
up_2 = 1;
//delay();
}
if((up_1==1) && (RA2 == 1)){
RC1 = 0; //Sets The RC1 to digital output 0
RC2 = 1; //Sets The RC2 to digital output 1
//delay();
up_1 = 0;
}
if((up_2==1) && (RA1 == 1)){
RC1 = 0; //Sets The RC1 to digital output 0
RC2 = 1; //Sets The RC2 to digital output 1
//delay();
up_2 = 0;
}
}
}
void delay(){ //Some delay...
unsigned char i,j,k;
for(i=0;i<0x20;i++)
for(j=0;j<255;j++)
for(k=0;k<255;k++);
}