Creating Light with LEDs (Scratch)
Start by watching the two videos listed below. The first will show you how to attach components to the Hummingbird board. The second will show you how to connect the Hummingbird to the computer and how to open Scratch when using the Hummingbird.
The Hummingbird kit contains two type of LEDs, single color LEDs and tri-color LEDs. Single color LEDs have two wires, while tri-color LEDs have four wires.
Single Color LEDs
A single color LED can be connected to one of four ports labeled “LEDS” on the Hummingbird board. Since you have four ports, you can connect up to four single color LEDs. The black LED wire should be connected to the ‘-’ terminal, while the colored wire should be connected to the ‘+’ terminal.
All the Hummingbird blocks are located in the More Blocks menu in Scratch. The HB LED block is used to control a single color LED. This block requires two numbers. The number on the left is the number of the Hummingbird port to which the LED is attached. This will be a number between 1 and 4. The second number is the intensity of the LED. This is a number between 0 and 100. 0 means that the LED is off, and 100 means that the LED is at maximum brightness. What do you think the program below will do? After you make a hypothesis, try it and find out (the wait block is on the Control menu).
Exercise: Modify this program so that the LED blinks on and off repeatedly. What Control block can you use to do this?
Building Tip: LEDs are quite small, but you can use a styrofoam ball to diffuse the light. This will make the light appear larger.
Programming Tip: When Scratch reaches an HB LED block, it sets the LED and moves immediately to the next block. This means that if you do not have a wait block between two commands for the same LED, you may not see the effects of the first block. For example, you may not see the LED turn on when you run the script below. Place a wait block between the HB LED blocks in order to see the LED turn on and then off.
A tri-color LED can be attached to one of the two ports labeled “TRI-COLOR” on the Hummingbird board. The four wires of the tri-color LED are red, green, blue, and black. The black wire should be connected to the ‘-’ terminal. The red wire should be connected to the ‘R’ terminal, the green to the ‘G’ terminal, and the blue to the ‘B’ terminal.
The tri-color LED actually has three tiny light elements inside it. One is red, one is green, and one is blue. This is important for programming the tri-color LED. The HB triLED block is used to control a tri-color LED. This block requires four numbers. The number on the left is the number of the port to which the tri-color LED is attached (1 or 2). The other numbers are labelled R, G, and B. R controls the amount of red light from 0 (none) to 100 (maximum brightness). G and B control the amount of green and blue light, respectively, from 0 to 100.
What color will the tri-color LED be after you run the block below? How will you turn the tri-color LED off?
Exercise: Make a tri-color LED blink on and off in your favorite color at least ten times in five seconds. Then modify your program so that the tri-color LED blinks in random colors at least ten times in five seconds.