hello,
i am try to code switching code which work some thing like this
when code start pin 1 on and pin 2 off
and continuously check if pin 3 off than
pin 1,2 off
else
if last time pin 1 on than do this
pin 1 off and pin 2 on
if last time pin 2 on than do this
pin 1 on pin 2 off
i try following code;
Moderators note: please use code tags for pieces of code
i am try to code switching code which work some thing like this
when code start pin 1 on and pin 2 off
and continuously check if pin 3 off than
pin 1,2 off
else
if last time pin 1 on than do this
pin 1 off and pin 2 on
if last time pin 2 on than do this
pin 1 on pin 2 off
i try following code;
C:
int a = 0;
void main() {
TRISA.F0 = 0; //pin1
TRISA.F1 = 0; //pin2
TRISA.F2 = 1; // input pin
PORTA.F0 = 1;
PORTA.F1 = 0;
Delay_ms(100);
while(1){
if(PORTA.F2 == 0){
PORTA.F0 = 0;
PORTA.F1 = 0;
Delay_ms(1000);
if( a == 1)
{ a=0;}
else{a=1;}
}
else
{
if(a==1){
PORTA.F0 = 0;
PORTA.F1 = 1;
}
else {
PORTA.F0 = 1;
PORTA.F1 = 0;
}
}
}
}
Last edited by a moderator: