Reputation: 11
I'm new to programming, and I became stuck here where I have to write an algorithm and pseudo code for this flowchart, but I'm confused on how to do the loop delay 2 seconds, or the add 2 seconds until it hits 10.
Thanks for your help!!!!
Upvotes: 0
Views: 4037
Reputation: 827
The pseudo code would be:
while (counter < 10)
{
sensor read = read the door;
while (sensor read == closed)
{
counter = 0;
sleep 2000ms;
}
counter += 2;
sleep 2000ms;
}
sound alarm;
Upvotes: 0
Reputation: 2634
I think that psuedocode can sometimes be harder than writing real code for people who are just starting. The psuedocode for those instructions can be pretty-well exactly as in the flowchard:
How to do the loop delay 2 seconds:
while (door_sensor_read is no)
sleep for 2 seconds
and the add 2 seconds until it hits 10:
Upvotes: 1