To start using Snap!, 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.
Click Find Robots. Your Finch robot will appear. Click on the name of the robot and then click Connect. Then select Level 4 in the pop-up menu.
This is the Snap! window. It has a few different parts. To write a program, you will drag blocks from the Blocks area to the Scripts area. In Snap!, programs are also called scripts. You can use Snap! to write scripts that use the Finch or scripts that use cartoon characters called sprites. This lesson will focus on the Finch.
The Blocks area in Snap! contains 8 different menus – Motion, Looks, Sound, etc. Click on the different menus to get an idea of the blocks that they contain. The Finch blocks that you will use in this lesson are located on the Motion, Looks, Sound, and Sensing menus.
It is very important to save your work often! Otherwise, you might lose something important.
To save a new project in Snap!, click on File and then Export project. Give your project a name and then click OK. Your program will be saved as a .xml file. To open a file, select File and then Import. The video below also describes two other methods of saving.
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.
Now you can run your program by pressing the spacebar. Try using the spacebar to make the Finch move. Then click the Stop Finch block to stop the Finch.
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.’
Try out the program above. Then try several motor speeds between 0 and 100 in the Move Finch block (keep the speeds of the left and right motors the same). Describe two ways that you can change how far the Finch moves.
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).
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!
The Looks menu contains a block that you can use to change the color of the Finch’s beak. This is the Finch LED block. 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 Snap! 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.
Using the Finch adds three blocks to the Snap! Sound menu. The Say This block will cause the computer to speak whatever text you type into the block.
The Finch Buzzer 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 immediately on to the next block. The Finch Buzz+Wait block, on the other hand, will pause the program until the sound is done playing. Then the program will move on to the next block.
Write a program that uses two Say This blocks. What block do you need to place between your Say This blocks?
Use Finch Buzz+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).