How do I reset the digital value after it's triggered?

1 reply [Last post]
LiFeBrOn
Title: NooBot
Joined: 05/02/2014
Posts:
BotPoints: 3
User offline. Last seen 8 years 20 weeks ago.

int main()
{

while (a_button() == 0) {
if (digital(10) == 1)
{
motor(0,-100);
motor(2,100);
msleep(2000);
(Digital reset code here) <- A resetting while statement trap basically
}

}

return 0;
printf("Done");
}
Anyone know what I should put? The slides don't say anything about this.

Terry
Terry's picture
Title: NooBot
Joined: 06/08/2009
Posts:
BotPoints: 55
User offline. Last seen 5 years 18 weeks ago.

Digital(10) is a reading of the port #10 which is a digital input. The OS is constantly reading these ports; no reset is needed.
As the program is written the robot motors on #0 & 2 should turn on for 2 seconds each time a touch sensor on #10 is closed.
as soon as the A button is pressed the program ends.

I hope this answers your question.

History is a race, between Education and Catastrophe