I had Brandy send me an example of her program to clarify the
problem.
The program used a loop to repeatedly test the touch sensor and either go
forward or back up and turn. She could have used a logic value to exit the
loop but really the approach wasn’t the best to begin with.
A better solution would be to tell the motors to go forward “forever”, use
a WAIT block to wait for the touch sensor to be pressed, back up and turn.
This sequence can be repeated as many times as needed.
Of course a better programming approach would be to avoid duplicate code
and create a My Block for the “go forward forever, wait for the touch sensor,
back up” part. Then the main program would be MB, turn right, MB, turn
left, MB turn right. Alternatively, the MB could do the turn itself using
an input logic value to determine which direction to turn. Then the main
program would be MB, MB, MB.
I sent her examples of these solutions directly.
Thank you Brandy, for asking a good question!
Stuart
Roll
River Bend Robotics Coach
Sent: Monday, July 04, 2011 11:46 AM
Subject: [VADCFLL-L] Programming query- how to count inside of a
sensor loop?
I
created a maze for my students and let them go at it. One student choose
to use a touch sensor, which was a good idea. Now the maze had the robot
traveling 1 right turn, two left turns, and then a right to finish the maze. (
On average this maze took 1.5 hours to program for each group.) The
student ended up using a timer on the loop, allotting the loops enough time to
run until they finished their task and moving on to the next loop.
Not bad for a brand new programmer :)
But surely, there has to be a
away to make the loops count themselves. How would you tell the robot, after
each touch, count it, then stop after you reach "x" touches?
I am
really trying to wrap my head around the wires. I know there is a logic
and a math block that would possible to use for this idea, but that I can't seem
to figure out how to wire it up.
Any help to this end
would be greatly appreciated!
(Also to the coach and his son that was
considering an advanced robotic programming class on-line , I'm still eagerly
awaiting that news on that seminar set :)
Regards,
Brandy
To UNSUBSCRIBE or CHANGE your settings, please visit
https://listserv.jmu.edu/archives/vadcfll-l.html
and select "Join or leave the list".
VADCFLL administrative announcements
are sent via VADCFLL-ANNOUNCEMENTS-L. Visit
https://listserv.jmu.edu/archives/vadcfll-announcements-l.html
to subscribe.