ayush3504 icon

activateFoodTray

ayush3504 | PRO | 10/01/15 03:54:58 AM UTC | 0 ⭐ | 281 👁️ | Never ⏰ | []
text |

840 B

|

None

|

0 👍

/

0 👎

foodTrayActive : A boolean set to True when "hopper" is raised and beam-break is detected and False otherwise.
currentTime() : A function that returns system time
PWM : PWM output value in range 0-100. 0 Means off and 100 means on. Values in between are PWM values.
timeOut : Stores time out in seconds
time0 : Time variable to help time out
time1 : Time variable to help delay
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.
 timeOut <= 2
 int activateFoodTray(){
 	time0 <= currentTime()
	PWM <= 0
 	while(NOT foodTrayActive AND (currentTime-time1)>timeConstant){
		time1 = currentTime()
		PWM <= PWM + 5;
		if (currentTime-time0 > timeOut){
			break;
		}
 	}
}

Comments