|
Yes it only uses 1 pin to drive the motor, although it will require 1 pin for the pot to set the ADC reading and 1 pin for the fish trigger.
It is just a simple "For/Next" loop, (lookup for/next commands)
What happens is the "for Y = 0 to adc_count" sets the number of times it repeats the commands between the "For" and the "Next" lines of code.
If we said "for b1 = 0 to 9" (i had called the variable Y) then it would repeat the loop 10 times, as each time the program gets to the line that would say "Next b1" it would go back to the "For b1" line, each time it loops through the code it increases the value in the variable b1 until b1 = 9 then it exits the loop.
In the case of the example above the 9 is replaced with the value read from the pot for the adc reading.
You could use PWM but i think this is simpler and it allows you to change the pause length from 10mS to whatever to suit the period of operation and then adjusting the pot just sets how many bursts of pulses you send to the motor, or you might think of it as how many steps the motor will make, sorter like teeth on a cog and how many teeth to rotate to deliver x amount of food.
Its the same as flicking the switch to the motor on/off 10 times for example.
Pete.
|