Codingassignmenthelper | Home Codingassignmenthelper | University

Upload First Programs with Finch

Assignment :

Most of this code came from BirdBrain Tech; some was written for testing.

Required Python Skills: Creating and running a program | importing a library | printing text to the screen | accepting user input and storing it in a variable

This Finch is a small robot designed for students learning computer science. You can write programs to move and turn the Finch, light up its beak, and collect information with its sensors. As you write programs, you will be able to test your programs with the Finch in the real world!

The picture below shows the features of the Finch robot. In this lesson, you will learn to make the Finch move forward and backward. Future lessons will introduce more features of the Finch.

Image1

To use the Finch in Python, you must import the relevant library and declare an object that represents the Finch. This is shown in the sample code below. In addition, you should import the time module. You will use the sleep() function in this module to pause the program to give the Finch time to move

Image1

The Finch object contains the methods that interact with the Finch. In this activity, you will use the wheels() method to make the Finch move. This method requires two parameters. The first parameter controls the speed of the left wheel of the Finch, and the second controls the speed of the right wheel. Both parameters must be between -1 and 1. For example, the method call below sets both wheels to move forward at full speed.

Image1

To move the Finch forward, you must turn the wheels on, pause the program, and then turn the wheels off. An example program is shown below. The sleep() function takes a single parameter that is a number of seconds. To stop the Finch, you set the speed of both wheels to 0.

At the end of every Finch program, you must call the close() method to close the USB connection to the Finch. Otherwise, you will not be able to connect to the Finch the next time you run a program.


Image1

Exercise 1:

Create a new file named “FinchForward.py” and try out the program shown above. It should make the Finch move forward for 1 second.

Tip 1 :

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

Image1

Exercise 2 :

Try changing the time that the Finch should move. Can you make the Finch move forward for 5 seconds?

Exercise 3 :

Both speed parameters must be between -1 and 1. To make the Finch move in a straight line, the speeds for the two wheels should be the same. Try out the code shown below. How does the Finch move?

Image1

Exercise 4:

You can program the Finch to make a sequence of movements. The commands below will make the Finch move forward first at speed 0.25, then at speed 0.5, and then at speed
0.75. Try out this sequence. Then modify it so that the Finch moves backward instead of forward.

Image1

Exercise 5 :

Write a program that makes the Finch move forward, then backward, then forward, and then backward again. The robot should pause for half a second between each movement.

Exercise 6 :

Write a program that moves the Finch at five different speeds. The Finch should move for 4 seconds total.

Exercise 7 :

Write a program that asks the user for the Finch speed and then moves the Finch at that speed.

Exercise 8 :

Write a program that asks the user how many seconds the Finch should move and then moves the Finch forward for that number of seconds.

To Download Click Here > Upload First Programs with Finch.pdf
Codingassignmenthelper | Home Codingassignmenthelper | Home