Start by watching the video below to learn how to open Scratch when using the Finch.
Use the USB cord to connect the Finch to the computer. In order for the Finch to run a program, this cord must always be attached to the robot and to the computer.
Programming in Scratch
This is the Scratch window. It has a few different parts. To write a program, you will drag blocks from the Blocks area to the Scripts area. In Scratch, programs are also called scripts. You can use Scratch to write scripts that use the Finch or scripts that use cartoon characters called sprites. This lesson will focus on the Finch.
Saving Your Work
It is very important to save your work often! Otherwise, you might lose something important. Watch this video to learn how to save a program.
To save a new project in Scratch, click on File and then Save as (Save Project for Chromebooks using ScratchX). Give your project a name and then click Save. Once your project has a name, you can save it by going to File and then Save.
Moving the Finch
To move and turn the Finch, you will use the Move Finch block. The Finch has two motors, one for each wheel. The Move Finch block enables you to start these motors. The block requires two numbers. These numbers represent the speed of the left and right motors. Each number can be any whole number from -100 to 100.
The Move Finch block makes the Finch start moving. Drag a Move Finch block into the Scripts area and set both number to 50. This is your first program! Click on this block to run your program. The Finch will start moving forward. You may need to pick it up to keep it from driving off the table.
You may have already discovered that you can write multiple scripts in the Scripts area. Add a second script that stops the Finch when you press ‘x.’
Creating Longer Scripts
You can use the wait block to move the Finch for a certain period of time. For example, this program will make the Finch drive forward for three seconds and then stop.
What does it mean for the speed to be negative? Try several motor speeds between 0 and -100 (keep the speeds of the left and right motors the same).
Turning the Finch
So far, the speeds of the left and right motors have been equal. When these speeds are equal, the robot moves in a straight line. When the speeds are not equal, the Finch will turn.
Write a program that makes the robot turn a full circle to the left and then a half circle to the right.
Think about how you might make the Finch turn back and forth repeatedly. One way to do this would be to use a long sequence of commands, but it is much simpler to use the forever block in the Control menu. This block is called a loop. A loop is a programming structure that repeats a portion of a program. Look at the Control menu. Which of the other blocks do you think might be loops?
Other blocks can be placed inside the forever block. The forever block repeats the blocks inside it until you press the stop sign to stop the program. This loop makes the Finch turn left and right. The loop repeats the four blocks inside it over and over. After the second wait block, the program immediately goes back to the first block inside the loop, the block that turns the Finch to the left. What happens if you remove the second wait block?
Use a loop to make the Finch drive in a square. What actions does the Finch need to repeat? How many times should it repeat them? Note: It is hard to turn precisely with the Finch; the angles on your square do not need to be perfect.
To make your Finch turn more reliably, you should program it to turn slowly (speed 20-40). Also, don’t forget to hold the Finch’s cord while it is moving!
Color with the Finch
You can use the Finch LED color block to change the color of the Finch’s beak. The Finch’s beak actually has three tiny light elements inside it. One is red, one is green, and one is blue. This is important for programming the beak. The Finch LED color block requires three numbers, which 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.
Write a program to make the beak blink on and off repeatedly in your favorite color.
When Scratch reaches a Finch LED color block, it sets the beak and moves immediately to the next block. This means that if you do not have a wait block between two Finch LED color blocks, 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. The same is true for the Move Finch blocks; a pair of Move Finch blocks should have a wait block between them.
Sound with the Finch
The Finch buzz block activates the Finch’s buzzer. This block requires two numbers. The number on the left (Hz) gives the frequency of the sound; keep in mind that humans can only hear sounds in the range of 20 to 20,000 Hz. The number on the right (ms) gives the length of the sound in milliseconds. This block will start the buzzer and then move on immediately to the next block.
Write a program that uses two Speak blocks. What block do you need to place between your Speak blocks?
Use the Finch buzz and wait blocks to make the Finch play a short song.
You have learned how to use all the Finch outputs! Watch this video to review before completing the last exercise in this lesson.
Practice all of the things you have learned in this lesson by making the Finch move in a geometric shape, such as a triangle or pentagon. The Finch should buzz as it starts each side of the shape. For an added challenge, make the beak change to a different random color for each side of the shape (Hint: Explore the pick random block in the Operators menu).