Activity: Spike Drop

Find a way to drive the simulator rover into the green parking lot. Use your colour or ultrasonic sensor to help you find the safe zone. Watch out though, go to far and you’ll fall and get spiked!

Activity Demonstration

Setup

This activity requires no physical setup, just make sure you connect the Code Editor to the Robot Simulator. If your unsure what the Robot Simulator is or need help setting it up, see our post Getting Started With The Robot Simulator.

 

Here’s Our Approach

Solution 1

The first solution involves using the ultrasonic sensor. We use a repeat while true block, but instead of leaving it on true we tell it to repeat while the ultrasonic sensor detects a number larger than 55. Once our rover detects the warning wall suspended above the spikes within 55cm it means we are directly in our safe zone and can stop moving.

 

Solution 2

The second solution is a bit more dynamic, uses the colour sensor and will work better if you move the rover and it needs to detect green multiple times within the one program. The benefit here is that the program won’t end on green, but it keeps making sure the colour is detected. We do this by using an IF/ELSE statement inside of a while true loop. We look for the colour green as before, but this time instead of ending the loop we just keep telling the motors to stop moving, and any other colour we will still keep the forwards movement.

 

Related Posts

Previous
Previous

Activity: Line Following

Next
Next

Project Showcase: Daniel Boulton’s Autonomous Warehouse