start Wait for 10 seconds Set condition to awake Set energy to 5 Set condition to asleep Wait for 5 seconds Increase energy by 1 EG 10111/10112 Introduction to Engineering Copyright © 2009 University of Notre Dame EG 10111 31 Decrease energy by 1 Is energy ≤ 0? Is energy ≥ 5? Set condition to awake end no no yes yes Set condition to awake (INPUT) Set energy to 5 (INPUT) Initialize timer (COMPUTE) REPEAT the following REPEAT the following every second Read the timer (INPUT) Compare to 10 seconds, if equal or longer (DECIDE) STOP REPEAT If less than 10 seconds (DECIDE) EG 10111/10112 Introduction to Engineering Copyright © 2009 University of Notre Dame EG 10111 32 Increment the timer (COMPUTE) Decrement energy by 1 (COMPUTE) Compare energy to 0, if greater than Do nothing (continue repeating) If less than or equal, STOP REPEAT Set condition to asleep (COMPUTE or INPUT)
You've reached the end of your free preview.
Want to read all 6 pages?
- Fall '14