Shop OBEX P1 Docs P2 Docs Learn Events
Cannot update variable in c program on propeller — Parallax Forums

Cannot update variable in c program on propeller

hacktorioushacktorious Posts: 72
edited 2013-12-29 19:10 in Propeller 1
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);
}
}
}

Comments

  • hacktorioushacktorious Posts: 72
    edited 2013-12-29 19:10
    DOH, disregard this post. I noticed I accidentally deleted the pause in the else if, which was turning the light on so fast I could not see it.
Sign In or Register to comment.