Advertisement
ayush3504

activateFoodTray

Sep 30th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. foodTrayActive : A boolean set to True when "hopper" is raised and beam-break is detected and False otherwise.
  2. currentTime() : A function that returns system time
  3. PWM : PWM output value in range 0-100. 0 Means off and 100 means on. Values in between are PWM values.
  4. timeOut : Stores time out in seconds
  5. time0 : Time variable to help time out
  6. time1 : Time variable to help delay
  7. timeConstant : Specifies delay in seconds before while loop can execute again. The delay should be at lease as long as the time hopper takes to respond. Take an audio recording and observe waveform to get a precise value.
  8.  
  9. timeOut <= 2
  10.  
  11. int activateFoodTray(){
  12.  
  13. time0 <= currentTime()
  14. PWM <= 0
  15.  
  16. while(NOT foodTrayActive AND (currentTime-time1)>timeConstant){
  17. time1 = currentTime()
  18. PWM <= PWM + 5;
  19. if (currentTime-time0 > timeOut){
  20. break;
  21. }
  22.  
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement