Print

Snap!Finch Basics

Lesson Key

Lesson key available for teachers.   Get Access

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.

Programming in Snap!

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.

Saving Your Work

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.

Moving the Finch

Now that you have learned some of the basics of Snap!, you are ready to start using the Finch. We will start by moving the Finch forward. The blocks to move the Finch are at the bottom of the Motion menu. They are the Move Finch and the Stop Finch blocks.

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.

Exercise 1:

Change each 50 to 0 and click the Move Finch block again. This should make the Finch stop moving. You can also use the Stop Finch block.

Events

So far, you have been running your program by clicking on it. You can also use an event to start a program. An event is an action that the computer can recognize. For example, you might press a key on the keyboard. Click on the Control menu.

The second block on this menu is when key pressed. Drag this block into your program until it connects to the top of your script. Notice that the shape of this block shows you that it must be at the top of a script. It can’t be connected below another block.

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.

Click on the black triangle in the when key pressed block. A menu will pop up that will allow you to select other keys. Modify your program so that the Finch moves forward when you press ‘o.’

Exercise 2:

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.’

Tip:

You may need to carry the USB cord as the Finch moves. Otherwise, the cord may keep the Finch from moving and turning freely.

Creating Longer Scripts

The wait block can be found on Control menu. This block pauses the program for the number of seconds shown in the block. This number can be a whole number or a decimal number.

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.

Exercise 3:

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.

Exercise 4:

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.

Exercise 5:

Try the two programs shown below. How are these two turns different? How can you make the robot turn in the other direction?

Exercise 6:

Write a program that makes the robot turn a full circle to the left and then a half circle to the right.

Loops

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?

The repeat block is a loop that repeats the blocks inside it a certain number of times. For example, this program makes the Finch turn left and right ten times. To stop the Finch at the end of the script, you need to add a command below the repeat block.

Exercise 7:

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.

Programming Tip:

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

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.

Exercise 8:

What do you think the program below will do? After you make a hypothesis, try it and find out.

Exercise 9:

Write a program to make the beak blink on and off repeatedly in your favorite color.

Programming Tip:

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.

Sound with the Finch

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.

Exercise 10:

Write a program that uses two Say This blocks. What block do you need to place between your Say This blocks?

Exercise 11:

Use Finch Buzz+Wait blocks to make the Finch play a short song.

Conclusion

You have learned how to use all the Finch outputs! Watch this video to review before completing the last exercise in this lesson.

Exercise 12:

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).

Tip:

Use the indentation in the Finch’s tail to attach a marker with tape or velcro. Then the Finch will draw your shape! The corners of the shape will be rounded because the marker is attached to the Finch’s tail, rather than at its turning point.