Originally Posted by
Gutiarplyrinak
[CODE]var testimputs (var){
while (1){
if (PICBbits.RB5 = 0) //if imput A = 0
n==1;
if (PICBbits.RB4 = 0) //if imput B = 0
n==2;
if (PICBbits.RB3 = 0) //if imput C = 0
n==3;
else
n==0
}
You don't need a switch statement here... you already have it... Here's a made up example to give you the idea... Of course you're going to have to develop your own final version...
Code:
void DoB5On(void)
{
Beep(1000);
Sleep(1000);
Beep(0);
}
void DoB4On(void)
{
StartMotor(7,CLOCKWISE) ;
Sleep(1000);
}
void DoB3On(void)
{
StopMotor(7);
Beep(1000);
Sleep(10)
Beep(0);
}
int main(void)
{
while (1)
{
if (PICBbits.RB5 == 0)
DoB5On();
elseif (PICBbits.RB4 == 0)
DoB4On();
elseif (PICBbits.RB3 == 0)
DoB3On();
}
return 0;
}
Never mind that the function calls are just made up trash... look at how the button presses are handled in main and how the procedure for each is called as a result.