Robin Newman’s Lego© Mindstorms© Page A beginner’s journey 2
First, I built a small addition to the main model, using the available third motor to which I attached a handle. I then connected it to the gate assembly motor, so that I could operate it by turning the handle, controlling the release of balls down the track. I set up a small test program to display the output of the colour sensor for each ball, and thus ascertained that blue gave output 2, green 3, yellow 4, red 5 and the white background (when no ball was present) 6.
I then started the main program
My first attempt at the main program broke the problem into the following logical steps.
- return the rotating ball track to the zero, or parked position
- set the gate so that the upper rod is in the closed positon (after one run it will normally be there already)
- rotate the gate motor 180 degrees, allowing one ball to move under the sensor
- read the ball colour and enter a fiveway switch
- for colour numbers 2(blue) to 5(red), say the colour name and rotate the turntable motor no of rotations = colour number -1
- for colour number 6 (white), say Goodbye, rotate the turntable back to the parked position
- open the bottom gate rod by rotating the gate motor 180 degrees, which release the ball (if any), closing the upper gate rod
- wait 30 seconds to allow the ball to roll off the runway into the receptacle
- repeat the loop
This worked, fine, but the program was not very efficient, and the arm returned to the zero position between each ball, so I moved on to develop a more sophisticated version. more...