Go!Motion and Hummingbird
The Vernier Go!Motion sensor can accurately measure distance over a range of 0.15 to 6 meters. You can use this sensor to extend the capabilities of the Hummingbird and create exciting new projects using ScratchX.
Important Note: For this tutorial, you must use Windows. Go!Motion does not work with Chrome on a Mac at this time.
Setting Up Your First Project
There are several steps required to set up the hardware for this tutorial. Be sure to follow these instructions carefully to properly set up Go!Motion and the Hummingbird to work together.
- Connect both the Hummingbird and Go!Motion to USB ports on your computer.
- Download and install the Chrome Hummingbird Connection App. You will be using Chrome in Windows instead of on a Chromebook. Make sure that you can program your Hummingbird in ScratchX. Close ScratchX when you are finished.
- Download HummingbirdHID.js. Place this file on your desktop or in another location where you can find it easily.
- Set up the Go!Motion probe to work with ScratchX in Chrome. Download and install the Scratch Extensions Browser Plugin for Chrome in Windows.
- Next, click on this link to open a ScratchX project with the Vernier Go! Extension loaded. You will see a distance block under the More Blocks menu. You should also hear the Go!Motion begin to make a clicking noise (it may take a few seconds).
- Click on the distance block to ensure that you can measure the distance in meters between the Go!Motion probe and the nearest object.
- Right-click on Load Experimental Extension; this option will not appear unless you right-click. Select HummingbirdHID.js and then click Open. You should see the Hummingbird blocks appear.
- Open the Chrome Hummingbird Connection App. Do NOT click the “Open Scratch” button. Now you can use both the Hummingbird blocks and the Go!Motion block in ScratchX. You are ready to start programming!
After Your First Project
Once everything is installed, there are only three steps that you need to start a new programming project with Go!Motion and Hummingbird:
- Click on this link to open a ScratchX project with the Vernier Go! Extension loaded. Remember, it may be a few seconds before the Go!Motion starts to click.
- Right-click on Load Experimental Extension. Select HummingbirdHID.js and then click Open. You should see the Hummingbird blocks appear.
- Open the Chrome Hummingbird Connection App. Do NOT click the “Open Scratch” button. Now you can use both the Hummingbird blocks and the Go!Motion block in ScratchX.
In this project, we created an elevator. We used Go!Motion to measure the position of the elevator in centimeters. Our Scratch project compares this to the desired position of the elevator, which is set by the user. The Hummingbird gear motor moves the elevator up or down until the distance measured by Go!Motion is close to the desired distance.
To create an elevator, you need a pulley. We used a 3D printer to create ours, but you could also glue an empty spool onto a wheel attached to the gear motor. We attached the motor to a ring stand; the string ran from the pulley over the ring to the top of the elevator box. The Go!Motion was placed on top the ring facing down toward the elevator box.
Start your Scratch program by creating a variable to hold the Go!Motion probe reading. We called our variable actual distance. Use a forever loop to continually set this variable equal to the value of the Go!Motion probe. We have chosen to multiply the distance by 100 to get a reading in centimeters instead of meters.
Create a second variable named target distance. On the stage, right-click on target distance and select slider. This creates a slider that you can click and drag to change the value of this variable. You can also set the maximum and minimum values of the slider here.
Next, add an if then else block to your loop. You will use this block to decide whether actual distance is close to target distance. If the difference between these two values is less than 2 centimeters, turn the motor off. Otherwise, you need to adjust the position of the elevator.
Next, nest another if then else block inside the if portion of the first one. This is where you will decide whether to move the elevator up or down. If actual distance is greater than target distance, then the elevator should move up. Otherwise, the elevator should move down. The direction of the elevator movement is determined by the sign of the motor speed. For us, a negative motor speed moved the elevator up, but this will depend on how your motor is connected to the Hummingbird. We made the magnitude of the speed greater when the elevator was moving up. This was necessary because the dinosaurs riding in our elevator were a little heavy, so the motor needed more power to move them against gravity.
Now, as you move the slider for target distance, the motor should move the elevator up or down until it reaches the correct position. This is an example of a simple feedback loop. The Go!Motion probe provides information about the actual location of the elevator, and the robot adjusts the motor until the actual position matches the target position. Feedback loops are very important in robotics. They enable a robot to move until its sensors indicate that it has reached some goal. For example, feedback loops can also be used to make a robot track a line or follow a light source.
There are many other potential ways to combine Go!Motion and the Hummingbird! Try out your own and share it with us by emailing email@example.com.