Creating Movement with Motors (Snap!)
The Hummingbird kit works with three different kinds of motors: vibration motors, servo motors, and gear motors. Snap! blocks for all of these motors can be found at the bottom of the Motion menu.
A vibration motor can be attached to one of the two ports labeled “VIBRATION” on the Hummingbird board. It does not matter which wire is attached to ‘+’ and which is attached to ‘-.’
The Hummingbird Vibration motor block is used to control the vibration motor. This block requires two numbers. The number on the left is the port attached to the vibration motor (1 or 2) and the second number is the speed of vibration from 0 to 100. 0 means no vibration, and 100 means maximum vibration.
Exercise: In introductory lessons, you learned to use the if block. Snap! also includes an if else block. The if else block also contains a Boolean block. If the Boolean block is true, the top part of the if else block will run. Otherwise, the bottom part of the if else block will run. What do you think the script below will do? What happens when you place this script inside a forever loop?
Building Tip: Small bells can be attached to the vibration motor. Activating the motor will cause the bell to ring. Also, googly eyes can be attached to a vibration motor so that they move when the motor vibrates.
A servo motor is a motor that moves to a particular angle. The Hummingbird servo motor can rotate to any angle from 0° to 180°. When using the servo motor, you must also use the AC power adapter (or a battery pack). Otherwise, the Hummingbird board will not have enough power to run the motor.
The servo motor has a small plug. This plug should be placed on one of the four male servo connectors on the Hummingbird board. The black wire should be connected to the ‘-’ pin, the red wire to the ‘+,’ and the yellow wire to the ‘S.’
Use hot glue to attach a popsicle stick to the white plastic circle on the servo motor. This will help you to see the movement of the servo motor more easily.
The Hummingbird Servo motor block is used to move the servo motor. It requires two numbers. The number on the left is the port attached to the servo (1-4) and the second number is the angle (0° to 180°). The command below should move a servo motor attached to port 1 to 0°.
Try out the script shown below. What problem do you observe? How can you fix this problem?
Exercise: Write a program to make the servo motor “dance” to one of the sounds in the Scratch library.
The gear motor can be attached to either of the ports labeled “MOTORS” on the Hummingbird board. It does not matter which wire is attached to ‘+’ and which is attached to ‘-.’ When using the gear motor, you must also use the AC power adapter (or a battery pack).
The Hummingbird Motor block is used to control the gear motor. This block requires two numbers. The number on the left is the port attached to the motor. The number on the right is the speed of the motor. This number can be any whole number from -100 to 100.
Exercise: Use a small screwdriver to attach a wheel to the motor so that you can see it move more easily. Try several speeds between 0 and 100. Describe how the speed affects the motor. Try several negative speeds. What does it mean for the speed to be negative?