---
title: "Activity: Spike Drop"
date: "2022-02-23"
categories: ["All", "Simulator Activities"]
tags: ["Colour Sensors", "Branching", "Iteration", "Ultrasonic", "Robot Simulator", "Beginner"]
excerpt: "Simulator activity for learning ultrasonic, colour sensor and iteration."
featuredImage: "/images/resources/spike-drop.png"
---

[

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/d48b056d-c05e-4abd-aceb-0e397c551283/Simulator+Indicator.png)

          ](/robot-simulator)

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!

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/c5ccabcf-2e0e-4a45-943d-85780203bb1f/spike-drop-demo.gif)

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.](https://micromelon.com.au/resources/robot-simulator)

### Here’s Our Approach

#### Solution 1

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/6d00470f-7747-44c6-8654-4909fed71a4c/spike-drop-answer-1.png)

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**

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/e4138ffa-d19c-4fc1-a8b6-ce698d0179f0/spike-drop-answer-2.png)

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

          Resources

      [

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/1639455538805-9NI7CPKR7IYG6D4RBKAN/high+quality+sumo.png)

  ](/resources/creating-a-sumo-unit)

	[All](/resources?category=All)

                [Creating A Sumo Unit For Your Digital Technologies Class](/resources/creating-a-sumo-unit)

	[All](/resources?category=All)

How to run a sumo unit in your digital technologies classroom.

                [Read More &#8594;](/resources/creating-a-sumo-unit)

	[All](/resources?category=All)

      [

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/1637464845856-BBPD7GTIIHHOSJCFORWF/the+ultrasonic+sensor.png)

  ](/resources/ultrasonic-sensor)

	[All](/resources?category=All), [Guides](/resources?category=Guides)

                [The Ultrasonic Sensor](/resources/ultrasonic-sensor)

	[All](/resources?category=All), [Guides](/resources?category=Guides)

Learn all about the ultrasonic sensor!

                [Read More &#8594;](/resources/ultrasonic-sensor)

	[All](/resources?category=All), [Guides](/resources?category=Guides)

      [

![](https://images.squarespace-cdn.com/content/v1/60a43bf842d7b601064a8828/1625616494179-LZHZP5MUA0E0MQKEB7HC/cropped+image+4.png)

  ](/resources/year-7-digital-tech-at-st-peters)

	[All](/resources?category=All), [Customer Stories](/resources?category=Customer+Stories)

                [Case Study: Year 7 Digital Tech at St Peters Lutheran College](/resources/year-7-digital-tech-at-st-peters)

	[All](/resources?category=All), [Customer Stories](/resources?category=Customer+Stories)

See how Meg Foley at St Peters conducted a challenge for their Year 7s using Micromelon.

                [Read More &#8594;](/resources/year-7-digital-tech-at-st-peters)

	[All](/resources?category=All), [Customer Stories](/resources?category=Customer+Stories)
