Cannot update variable in c program on propeller
hacktorious
Posts: 72
Why won't this work? For some reason it will not update dir..... It just keeps running the first if and never gets enters the else if. Am I doing something wrong? I don't have a ton of experience in C. I'm a Java/Ruby programmer. Why won't the variable update? Thanks.
int main() // main function
{
int dir = 1;
while(1){
int button = input(21);
if(button == 1 && dir == 0){
high(4);
pause(3000);
low(4);
dir = 1;
} else if(button == 1 && dir == 1){
high(6);
dir = 0;
pause(3000);
low(6);
}
}
}
int main() // main function
{
int dir = 1;
while(1){
int button = input(21);
if(button == 1 && dir == 0){
high(4);
pause(3000);
low(4);
dir = 1;
} else if(button == 1 && dir == 1){
high(6);
dir = 0;
pause(3000);
low(6);
}
}
}
Comments