This demonstrates ultrasonic range detection. It simulates stopping a vehicle’s motor before it crashes into an obstacle
Note: This app is not in the Classroom App Preload set of Apps that comes with a basic Kookaberry. It can be found in the Project Apps set that can be downloaded from within the Tutorial: Installing Apps on your Kookaberry
Read the description of the analogue ultrasonic sensor to learn how it works and the echolocation principle it uses.
Step 1: Setup
Plug an analogue ultrasonic sensor into P4.
Now get two small pieces of Blu Tack or similar and stick the sensor to the back of the Kookaberry’s handle as shown below.
After sticking the sensor to the back of the Kookaberry, connect the DC fan module to P2.
Step2: Running the App
Hold the fan away from any obstacle (particularly your fingers!) as it will start spinning as soon as you press Button B unless the screen shows STOP! and P2 is Off.
This, of course, is the object of the demonstration – when the sensor detects an obstacle at or nearer the target distance it will stop the motor.
Tip: Stick the fan to the edge of a desk with Blu Tack
Now navigate to the CloseToMe app in the Kookaberry menu and press Button B to run.
These three screen shots are what you see when you move the sensor (now attached to the back of the Kookaberry) closer to an object – eg a tabletop. It shows a series of evermore urgent instructions as you get closer to the target.
What is showing on the screen?
- Top Row: Name of app
- Second Row: Warning; D is distance of sensor from target; T is a settable distance from the target which displays the STOP! warning and turns P2 to OFF when reached.
- Third Row: Shows which pin (P4) to use for sensor; which pin (P2) to use for output peripheral (DC fan motor); and status of P2 (On or Off)
- Fourth Row: Button A is Exit from app; Button C decreases the target distance (T), and Button D increases it.
The three LED’s on the front of the Kookaberry will also light up like traffic lights. Green for GO; Orange for SLOW; and Red for STOP
Using the App for obstacle avoidance
With someone else holding the fan, move the sensor towards a variety of obstacles and see the screen warnings change as the you approach a target. Use Buttons C and D to change the distance at which the STOP warning is displayed.
Using the App for distance measurement
Disconnect the fan and use the app as a distance measuring device. The reading to the right of D on the screen is the distance from the sensor to the target.
Why do you think it is difficult to accurately measure the distance to your target when there are other objects nearby?
Change the app from one where it turns off a motor when it reaches its target distance (T), to one which sounds a buzzer when the target distance is reached.
Tip: Use a second Kookaberry running the Logic App