programming with finches - lewis universitycs.lewisu.edu › ~klumpra › grew2013 ›...

Post on 09-Jun-2020

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Programming with Finches GREW 2013

Overview

Computers and Algorithms

Overview of control structures

Introduction to Finches and Snap

Examples of control structures using Finches

What is a Computer?

A device that performs high-speed mathematical and/or logical operations or that assembles, stores, correlates, or otherwise processes information.

Hardware

What are Computers Good At?

Doing calculations and comparisons

Producing the same answer every time Like calculating the sum of hundreds of numbers

Computer don’t tire of tedious tasks

Storing information

They don’t forget information

Looking up information quickly

Search through a phone book to find the customer name for a phone number

4

But computers aren’t intelligent…

They don't "think"

At least not yet

They required detailed instructions in order to perform tasks

These instructions are called algorithms

5

Programming Languages

Computers are usually programming using a "language"

A limited vocabulary of instructions that can be obeyed

Computers always obey instructions exactly

Even if they produce incorrect results

This often makes programming frustrating

Marching Orders

What happens if people follow instructions exactly?

Example: go through that door

People don't always follow instructions exactly

Don't need to

But computers do

CS Unplugged

A collection of free learning activities that teach Computer Science without a computer

Instead use engaging games and puzzles

http://csunplugged.org

Finch Robots

Robot designed for Computer Science Education Carnegie Mellon's CREATE lab

Low-cost ($99 each)

http://www.finchrobot.com

Features: Light, temperature, and obstacle sensors

Accelerometers

Motors

Buzzer

Full-color beak LED

Pen mount for drawing capability

Plugs into USB port - no batteries required

Snap!

Snap! is a drag and drop programming environment

A descendant of Scratch

BirdBrain Robot Server, that allows Finch to be controlled from within Snap!

http://www.hummingbirdkit.com/learning/software/snap

Finch Blocks

Motion Commands

Move Finch Left: Right

Sets the power to the left and right wheels.

The range is -100 to 100

Stop Finch

Stops the Finch

Looks Commands

Finch LED R: G: B: Sets the color of the Finch's beak

R, G, and B values control the intensity of the red, green, and blue elements in the Finch's beak

Range is 0 to 100 for each color

Finch Blocks

Sound Commands

Finch Buzzer Hz ms

Plays the Finch's buzzer with a sound of the frequency specified for the time specifie

Range is 20 to 20,000 for frequency.

Finch Buzz+Wait Hz ms

Does the exact same thing as Finch Buzzer, but also halts further program execution for the amount of time specified.

Say This Block

Causes the computer to speak whatever text is placed in the box

Finch Blocks

Sensing Commands

Finch light sensor

Finch X/Y/Z Acceleration

Finch Orientation

Returns the current orientation of the Finch

Possible responses are: level, upside down, beak up, beak down, left wing down, right wing down

Finch obstacle sensors

Finch Temperature Celcius

Finch Temperature Fahrenheit

Control Structures

When you write an algorithm, you need to focus on the "type'' of behavior that you need to handle.

Sequential steps

Easiest ones because one step simply follows the previous one

Conditional statements.

One or more conditions are used to determine which one out of many alternative actions should take place.

Iteration (repetition) statements.

These statements provide behavior that is repetitive.

Sequential Statements

Begin using the "when clicked" block

Use the "wait secs" block to pause so that you can see an action occur

Snap together Finch blocks to have the robot move, make sounds and change colors

Conditional Statements

Use these blocks to chose between alternative actions

Iteration Statements

Use these block to repeat actions

top related