Tabletop Treasure
In this challenge we had to build a robot that was able to find a yellow square that was somewhere on a table with out falling off the table. We built our robot with two colour sensors to make it so even at a sharp angle the robot would sense the edge before it fell off.
Psuedocode:
Loop
Move forward
Color sensor - sense change of color = black
If color change is true - backup and turn around
Loop - end after infinity
Loop
Move forward
Color sensor - sense change of color = yellow
If color change true - Stop Cheer and stop program
Loop - end after infinity
Loop
Ultrasonic sensor sense x centimeters
If something sensed x centimeters in front increase speed to 100 and move forward
Wait 0.5 seconds before checking again
Loop - end after infinity
This is what our code actually looks like
This challenge was actually a lot of fun because we, as a class, got to sort of put our robots against each other so we were allowed to put offensive parts on the robot. Our robot had these spear like attachments on the front and when it sensed a robot close to it it would dash at it and get it out of the way all while searching for the yellow square. When it went over the yellow square it would stop and celebrate. Here is a video.
It was actually a pretty easy challenge to complete because we had already done a challenge that was very similar. We didn't run into any problems during this challenge.