LoyC
Junior Member level 1
//on/off funcion
#include <pic.h>
#include <htc.h>
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BORDIS);
unsigned int RA0,RA1,RA2,RA3,RB0,RB1,RB2,RB3,RB5;
void main(void)
{
ANSEL = 0x00; //select POTA & PORTB as digital i/o
TRISA = 0xFF; //select PORTA as input
TRISB = 0x00; //select PORTB as output
while(1)
{
if(RA0==1){ //switch on S1
RB0=1; //set RB0 as high
RB5=0; //enable TE
}
else{ //switch off S1
RB0=0; //set RB0 as low
RB5=0; //enable TE
}
if(RA1==1){
RB1=1; //set RB1 as high
RB5=0; //enable TE
}
else{
RB1=0; //set RB1 as low
RB5=0; //enable TE
}
if(RA2==1){
RB2=1; //set RB2 as high
RB5=0; //enable TE
}
else{
RB2=0; //set RB2 as low
RB5=0; //enable TE
}
if(RA3==1){
RB3=1; //set RB3 as high
RB5=0; //enable TE
}
else{
RB3=1; //set RB3 as low
RB5=0; //enable TE
}
}
return 0;
}
i've wrote a program here. Can any1 tell me what's wrong with it because error message keep poops up everytime i try to build it.
#include <pic.h>
#include <htc.h>
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BORDIS);
unsigned int RA0,RA1,RA2,RA3,RB0,RB1,RB2,RB3,RB5;
void main(void)
{
ANSEL = 0x00; //select POTA & PORTB as digital i/o
TRISA = 0xFF; //select PORTA as input
TRISB = 0x00; //select PORTB as output
while(1)
{
if(RA0==1){ //switch on S1
RB0=1; //set RB0 as high
RB5=0; //enable TE
}
else{ //switch off S1
RB0=0; //set RB0 as low
RB5=0; //enable TE
}
if(RA1==1){
RB1=1; //set RB1 as high
RB5=0; //enable TE
}
else{
RB1=0; //set RB1 as low
RB5=0; //enable TE
}
if(RA2==1){
RB2=1; //set RB2 as high
RB5=0; //enable TE
}
else{
RB2=0; //set RB2 as low
RB5=0; //enable TE
}
if(RA3==1){
RB3=1; //set RB3 as high
RB5=0; //enable TE
}
else{
RB3=1; //set RB3 as low
RB5=0; //enable TE
}
}
return 0;
}
i've wrote a program here. Can any1 tell me what's wrong with it because error message keep poops up everytime i try to build it.