Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 ›...

18
Programming with Finches GREW 2013

Transcript of Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 ›...

Page 1: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

Programming with Finches GREW 2013

Page 2: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

Overview

Computers and Algorithms

Overview of control structures

Introduction to Finches and Snap

Examples of control structures using Finches

Page 3: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 4: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 5: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 6: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 7: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 8: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

CS Unplugged

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

Instead use engaging games and puzzles

http://csunplugged.org

Page 9: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 10: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures
Page 11: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 12: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 13: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 14: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 15: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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.

Page 16: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

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

Page 17: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

Conditional Statements

Use these blocks to chose between alternative actions

Page 18: Programming with Finches - Lewis Universitycs.lewisu.edu › ~klumpra › grew2013 › finches.pdfwith Finches GREW 2013 . Overview Computers and Algorithms Overview of control structures

Iteration Statements

Use these block to repeat actions