The goal of this activity was to Create a program that would randomly select a course of action when it came within 25 cm of an object. I had to change my switch block from 'flat' view to 'tab' view and each tab would perform a different movement.
The random block chooses a number between 0-3.
Pseudo-coding: Move block: go forward
Loop, ultrasonic sensor
Random block connected to a tab switch block.
First tab- go backwards one rotation and then turn left and continue moving.
Second tab- go backwards one rotation and then turn right and continue moving.
Third tab- turn left and continue moving.
Fourth tab- turn right and continue moving.
All inside one giant loop
I didn't have any problems with this program... probably because It isn't really performing a task.
No comments:
Post a Comment