Summary
Num | Title | Due | Kind | Max Pts | Weight |
---|---|---|---|---|---|
13 | Bicycle Computer – Project Summary | May 17 | FP | 5 | 5 |
12 | Button Trigger | Apr 29 | HW | 10 | 5 |
11 | Binary Counter | Apr 15 | HW | 10 | 5 |
10 | Calculator | Apr 1 | HW | 25 + 5 EC | 5 |
09 | Maze Game | Mar 25 | HW | 22 + 3 EC | 5 |
08 | Golden Section | Mar 17 | HW | 23 | 5 |
07 | Journal Check | Feb 28 | CL | 2 | 3 |
06 | The Name Game | Feb 28 | HW | 5 | 5 |
05 | Implications of Watson | Feb 18 | HW | 16 | 5 |
04 | The Handshake Problem | Feb 10 | HW | 3 | 5 |
03 | Diversity in Binary | Feb 08 | CL | 2 | 5 |
02 | UW CSE Research Report | Feb 07 | HW | 15 | 5 |
01 | Day 1 Questions | Feb 01 | CL | 2 | 3 |
00 | Student Info Survey | Feb 01 | CL | 1 | 1 |
Assignment 13: Bicycle Computer
Now, in the home stretch of the semester, we are moving on to the final project. This challenge is to make your own bike computer with an Arduino.
An Arduino is the perfect platform to use to explore this topic. It will allow you to integrate work in both software and electronics. And it is a good engineering and design challenge for a very practical application.
We will approach this problem as a small technology company would tackle a complex problem — by dividing it into smaller pieces and having small teams work on the different components separately. Then one team will have the job to integrate all of the components into a working system.
In class , a group of students did some brainstorming about what those individual component tasks might be. Here is a list, with the people who have signed up for each component:
Magnetic Sensor | detect and calculate RPMs | Jordan, TJ |
Clock Module | get real time and display | Jacob, Spencer (?) |
Temperature Sensor | detect & display temp | Ethan, Mitchell |
Ambient Light Sensor | detect ambient light levels | David |
LED Speed Display | calculate speed and indicate it on LEDs | Mack, Travis J |
Sound Output | provide audio feedback | |
Brake Lights | flash lights while braking | Kevin, Minnie |
LCD Text Display | display text info | Travis S |
Bike Sensor Rig | make mechanical harness for sensors | Ben, Anthony |
Arduino Enclosure | make enclosure for mounting Arduino | Anthony, Ben |
Project Website | capture development process | Salman, Henry, Fillmon |
System Integration | blend all code modules together to one app | Conor, Jack, Mike, Forrest |
Master Schedule | develop master timeline for all tasks | Conor, Jack, Mike, Forrest |
Project Coordination | communicate and coordinate interfaces between all modules | Conor, Jack, Mike, Forrest |
Here are some other possible enhancements if there is time:
Phase 2 | |
---|---|
Turn Signals | make tail lights |
EL Wire Lights | light up the franme |
Motion Sensor | use accelerometer to detect gradient |
Your first assignment for this project is to complete a short project component document describing the piece of the system you will make, and some details about it. Download this template — Component Summary — and edit it to fit your particular piece of the system. Change the text in red, and hand in a printed copy.
GRADING (Final Project) | |
---|---|
Component Summary Document | 5 pts |
TOTAL | 5 |
DUE: May 17 on paper in class.
Assignment 12: Button Trigger
Up til now, your Arduino programs have just dealt with digital output — flashing LEDs. Now it’s time to get interactive and handle digital input, from a button.
For this assignment, you will implement a program that responds to button presses and then uses them as triggers to do something. You will combine this program with your binary counter from Assignment 11, and make the counter step up one number each time the button is pressed.
Then you will add a second button to the circuit and have one button move the counter up and the other one move the counter down with each press. The counter will display the numbers in binary. Use the same pins for the LEDs as you did in the binary counter.
Here is a picture of how to wire the circuit on your breadboard for the button to be connected to pin 2 on the Arduino. Use a a 10K (10,000) ohm resistor.
Below is an example sketch you can use if you need help getting started with this. This program simply handles detecting a button press and then flashes one LED to indicate the number of times the button has been pressed. You will have to modify it to do the logic of counting up and down as decribed above, and to display the numbers in binary. You can copy and paste this code into a new Arduino sketch, and then save it.
/* ButtonTrigger ahdavidson 4/25/11 This program detects when the button has been pressed and uses that to trigger some action. Based on the StateChangeDetection example, by Tom Igoe */ // constants to make the code more readable const int buttonPin = 2; // the pin that the pushbutton is attached to const int ledPin = 13; // the pin that the LED is attached to // variables that are changed by the program int buttonPushCounter = 0; // counter for the number of button presses int buttonState = 0; // current state of the button int lastButtonState = 0; // previous state of the button // configure the pins to the right mode void setup() { pinMode(buttonPin, INPUT); pinMode(ledPin, OUTPUT); } // the main loop will constantly check to see if the button has been pressed // if it has, a counter is incremented, and then some action can be taken void loop() { // read the state of the button buttonState = digitalRead(buttonPin); // check to see if it different than the last time we checked if (buttonState != lastButtonState) { // either the button was just pressed or just released if (buttonState == HIGH) { // it was just pressed buttonPushCounter = buttonPushCounter + 1; // anything you put in here will be happen each time the button is pushed // this example flashes the LED the number of times the button has been pushed so far for (int i = 0; i < buttonPushCounter; i++) { digitalWrite(ledPin, HIGH); delay(250); digitalWrite(ledPin, LOW); delay(250); } } } // this is necessary to be able to detect the triggering lastButtonState = buttonState; }
Here is some pseudo-code for the algorithm you will have to construct to have the button presses trigger the binary counting. Remember that pseudo-code is not a literal script for the Arduino code. It is a sketch for how to think about writing your code.
To grade this project, I will need to see your circuit design, and you will submit your code sketch (.PDE file) in the course dropbox. I will run it on my circuit to verify your solution.
GRADING (Homework) | |
---|---|
Circuit implemented correctly | 5 pts |
Counter sketch sequence correct | 5 pts |
TOTAL | 10 pts |
DUE: Friday, April 29 in the course dropbox.
Assignment 11: Binary Counter
Now that you have had a chance to experiment with the Arduino hardware and software, it is time to do an assignment to make sure you can design a basic circuit and program a sketch to manipulate it.
For this assignment, you will create a 3-bit binary counter using three LEDs. Your counter should display the decimal numbers from zero to seven in binary, using one LED to represent each binary digit.
Recall that to count in binary, each digit represents either a zero or a one. You will represent a zero by having the LED off, and a one by turning on the LED. The counting sequence looks like this:
Binary : Decimal 0 0 0 : 0 0 0 1 : 1 0 1 0 : 2 0 1 1 : 3 1 0 0 : 4 1 0 1 : 5 1 1 0 : 6 1 1 1 : 7
Create a breadboard circuit like the one in these photos (and shown in the Electronics Basics slides linked below). You can use any kind of LED. Use 220 O (ohm) resistors for each one.
This is a circuit diagram that represents this design. You should get used to looking at these kinds of diagrams and working from them to build your circuit. You won’t always be provided with a photo reference; in fact, usually you won’t.
Connect the common ground on the breadboard (the black wire in the photo) to a GND pin on the Arduino. Then connect the three colored wires from the resistors in front of the LEDs to pins 10, 11, and 12 on your Arduino board. They must represent the binary number as follows:
- Pin 10: the least significant bit (the “ones” digit)
- Pin 11: the middle significant bit (the “twos” digit)
- Pin 12: the most significant bit (the “fours” digit)
Then write an Arduino sketch that flashes the LEDs in the sequence above, cycling through the numbers from zero to seven.
Here is an example sketch you can use if you need help getting started with this. This program simply flashes each of three LEDs in sequence. You will have to add the logic to do the counting. You can copy and paste this code into a new Arduino sketch, and then save it.
/* Blink3 ahdavidson: 4/9/11 Blinks 3 LEDs in sequence, turning each one on for 1/2 second. The LEDs are connected on pins 12, 11, and 10 and are blinked int hat order. */ void setup() { // set all LED pins to OUTPUT mode pinMode(12, OUTPUT); pinMode(11, OUTPUT); pinMode(10, OUTPUT); } void loop() { // turn the first one on and leave it on for 1/2 second digitalWrite(12, HIGH); delay(500); // now turn the first one off and the second one on, then leave it on for 1/2 second digitalWrite(12, LOW); digitalWrite(11, HIGH); delay(500); // second one goes off and then the third one goes on for 1/2 second digitalWrite(11, LOW); digitalWrite(10, HIGH); delay(500); // finally turn the third one off, and pause for another 1/2 second before starting over digitalWrite(10, LOW); delay(500); }
Here are some other resources you can consult if you need additional help:
- Electronics Basics: presentation slides with an explanation of basic electronic circuits for Arduino.
- Arduino Resources: be sure to check this page for other useful Arduino references and resources.
To grade this project, I will need to see your circuit design, and you will submit your code sketch (.PDE file) in the course dropbox. I will run it on my circuit to verify your solution.
GRADING (Homework) | |
---|---|
Circuit implemented correctly | 5 pts |
Counter sketch sequence correct | 5 pts |
TOTAL | 10 pts |
DUE: Friday, April 15 in the course dropbox.
Assignment 10: Calculator
This assignment will give you practice using broadcast messages and good programming structure in a more complex, object-oriented, interactive application.
Your task is to implement a basic calculator in Scratch. It will allow the user to enter digits and have the program interpret them as a number. It will simply keep a running total of the sum of all of the numbers entered.
This means that whenever the “+” button is clicked, your program will add whatever number has just been entered to a running total and display the total. When a new number is entered, the display should be cleared and the user can begin entering another sequence of digits to represent the next number to be added to the running total.
This may sound complicated, but you have probably used a calculator like this a lot in your life, so I hope the concept is clear.
This program should be written entirely using broadcast messages to mange all of the interactions between different sprites. All script blocks in the entire program should begin with one of the following “Control” blocks:
- When Sprite clicked: a button
- When I receive …: a message
- When Green Flag clicked: ONLY ONE, on the Stage
A sprite can, and probably will have more than one set of script blocks, but each set must begin with one of the blocks above.
This means that sprites will typically be doing one of two things. They will either be reacting to user input (a click) and then perhaps manipulating a variable, and sending a broadcast message to another sprite to do something. Or they will be waiting to receive a broadcast message to tell them to do something (like recalculate or update the display.
I have written a Scratch program that you can use to get started, if you wish. You can download it from the Scratch website at this link: Basic Calculator Starter Pack. (If you don’t have a Scratch login, you can get your own for free. If you don’t want to do that, I’ll give you one to use.)
This document has a summary of the Basic Calculator Starter Pack’s sprites and scripts: Basic Starter Pack Summary.
Whether you use that or create your own, your calculator should implement the following functions:
- 0 – 9 keys: process digits as they are entered and recalculate the number being entered after each digit. Display the number on screen. You can use a “Say” or “Think” block to do this on the “Display” sprite. (You do not have to create your own digit display on the calculator.
- + key: stop collecting digits of the current number add the value of the current number to the running total. Clear the display and show the total, until the next digit is entered, and then begin a new number.
- C key: clear the current number by setting it to zero and updating the display.
To see how the calculator should work in its basic form, here is a short video demo: Calculator Demo.
Here are some other resources you can consult if you need additional help:
- Messages: the slides from the presentation I gave with a basic explanation of message passing.
- Cat Horse Demo: this Scratch program demonstrates a simple broadcast message passing application.
If you finish the basic calculator, here are some things you can do for extra credit challenges:
- Implement more calculator functions than the basic ones in the assignment. In the Stage backgrounds of the Starter pack program, you will find an advanced calculator version, which has subtraction, multiplication, division, sign change, and equals buttons.
- For a real challenge, look at the full calculator version in those backgrounds, and implement memory registers and (if you dare) real numbers with decimal points.
- Another enhancement would be to use sprites that look like numbers for the display instead of just a “Say” or “Think” block.
GRADING (Homework) | |
---|---|
Basic Functionality
|
15 pts |
Scratch Program
|
10 pts |
Beyond basic features (Extra Credit)
|
5 pts |
TOTAL | 25 pts (+ 5 EC) |
DUE: Friday, April 1 in the course dropbox.
Assignment 9: Maze Game
This assignment will give you practice with using variables and keyboard events in Scratch.
Your task is to create a simple maze game, where the player uses the keyboard to navigate a Scratch sprite through a maze. Here are the rules of the game:
- Pressing the Left and Right arrow keys should turn the sprite 90 degrees to the left or 90 degrees to the right, respectively.
- Pressing the Up and Down arrow keys should move the sprite forward or backward 10 steps with each press, respectively.
- Create a variable that keeps track of the number of moves the player makes during the game. Each time the Up or Down arrow is pressed counts as one move. The variable should be displayed om the game board so we can always see the number of moves that have been made.
- When the player successfully reaches the end of the maze, have the sprite announce how many moves it took to get there.
- Pressing the space key should reset the game to its initial state: move the sprite to the initial position, reset the number of moves to zero, etc.
- Pressing the green flag should start the game, which should do everything that the Space key does. It should also have the sprite announce the beginning of a new game.
- Use this image for the maze: Maze Background. You can download this image, and then import it into your Scratch program as a background for the Stage. Feel free to use a different image, or make your own, as long as it is as least as complex as this one.
Here are some resources you can consult if you need additional help:
- Variables: the slides from the presentation I gave with a basic explanation of variables.
- Variable Demo: this Scratch program demonstrates the basic use of a variable. It also shows how to respond to a number of different keyboard events to make things interactive, as well as how to use various operators to do calculations and manipulations of variables.
- Conditionals: the slides from the presentation I gave with a basic explanation of conditionals.
- Conditional Demo: this Scratch program demonstrates the basic use of a conditional statement.
From studying the demo, you should be able to implement the game as described above. But, of course, this isn’t really a maze-following game, because the player could just ignore the walls of the maze and head right for the exit.
So we need some more rules. But start with the above version and get that working first. Then add the following rules. (Don’t worry if you don’t know how to do these yet. They require some additional programming constructs that we haven’t covered, like conditionals. We’ll cover that in the next few days. These are for the students who already know how to do this.)
- Do not let the sprite run over any walls. Make sure it checks to see if there is room to go in the direction it is headed without hitting the wall. If not, just ignore the Up or Down arrow move command, but still count it as a move!
- If the sprite reaches the end of the maze, make a little fanfare if it took less than 50 moves to do it.
- If the sprite takes more than 100 moves and still has not reached the end of the maze, let the player know and end the game with some obnoxious sound or action.
- Think up some other fun things to add to the game.
GRADING (Homework) | |
---|---|
Game Play 1
|
10 pts |
Game Play 2
|
6 pts |
Scratch Program
|
6 pts |
Extra features (Extra Credit) | 3 pts |
TOTAL | 22 pts (+ 3 EC) |
DUE: Friday, March 25 in the course dropbox.
Assignment 8: Golden Section
This assignment will give you practice with drawing in Scratch, using coordinate systems, animation, and a chance to use some math and creativity. You will also have to analyze a problem and break it down into smaller component tasks, and use pseudo-code to document it. The documentation of this project is an important part of the process, almost as much as writing the software.
Your task is to design and program an animation in Scratch that illustrates the mathematical construction known as the Golden Section (or the Golden Mean, or the Golden Rectangle).
In class, I demonstrated the geometrical construction of the Golden Section. This image is a snapshot of that algorithm. Your program should illustrate the steps of the construction, not just show the final result.
You should first analyze this construction and break down the animation into smaller tasks. For instance, if you have to draw four rectangles in total, then think about how you will draw those four individual rectangles and how they relate to each other.
First produce a step-by-step sketch of the geometric construction algorithm. Then write out the pseudo-code for that algorithm. Then you can implement it in Scratch. Here is a sample of what I am looking for in an algorithm description (sketch and pseudo-code): N-gon Draw. This is for the “N-gon Draw” program below. Yours does not have to include your Scratch code; the pseudo-code is the most important part.
You are free to exercise your own creativity in designing this animation, and encouraged to come up with a good educational, visual explanation of the Golden Section. It should show the basic geometry of the ratio and demonstrate the graphical relationship involved. (You do not have to illustrate the recursive nature of the rectangle. We’ll save that for later.) Here is the slide set I showed in class explaining the rectangle’s spiral magic: Golden Section.
Here are two helpful Scratch programs you can look at, download, and maybe learn something from:
- Pentagon Tutorial: this program, by Mike, shows one way to draw a pentagon correctly in Scratch. It’s a nice simple method, and helps you understand the stuff about angles of your sprites.
- N-gon Draw: this program, by me, uses trig functions to calculate coordinates on the circumference of a polygon and draw it. It also shows how to use a variable to control the number sides and the radius of the polygon.
After demonstrating the geometric relationship on a plain background, create a second Scratch program that allows you to create different size Golden Rectangles based on a variable that indicates the vertical dimension (height in pixels) of the rectangle. Your program should be able to draw a Golden Rectangle (just the rectangle, not all of the construction animation) based on any arbitrary value of the height. (This will require you to use the Scratch variable technique.)
Finally, add a background image of an example of a Golden Rectangle from nature or architecture, and draw your Golden Rectangle at the right location and size to overlay the rectangle on the background image.
GRADING (Homework) | |
---|---|
Golden Rectangle illustration
|
15 pts |
Variable size rectangle
|
4 pts |
Rectangle trace on image | 2 pts |
Design & creativity | 2 pts |
TOTAL | 23 pts |
DUE: Thursday, March 17 in the course dropbox.
Assignment 7: Journal Check
This is just a check that you have been keeping notes and required entries up to date in your course journal or notebook.
GRADING (Classwork) | |
---|---|
Journal entries made | 2 pts |
TOTAL | 2 pts |
DUE: Monday, February 28 check in class.
Assignment 6: The Name Game
OK, at last you start programming. Or “scratching,” as they say. Your first Scratch assignment is to make a simple animation using the letters in your name. The animation can be anything you like — be creative! This programming stuff is supposed to be fun. Use a separate sprite for each letter of your name and have each letter do something when the green flag is clicked. Each sprite should have a script that uses the “forever” block. Beyond that, go crazy and experiment a lot with as many blocks as you can find. Use the resources to poke around and try things. Here are two sample Scratch name programs you can look at for ideas. One is from another curriculum, and the other is one I made of my name. You can download them here to see how they work, and use them for ideas and techniques for your own animation.
- Name.sb: a Scratch program that does crazy stuff with Cami’s name
- Mr D.sb: a Scratch program that makes ME dizzy
GRADING (Homework) | |
---|---|
Separate sprites for each letter of your name | 1 pt |
Changing behavior for each sprite | 1 pt |
Using the “when green flag clicked” block | 1 pt |
Using the “forever” block | 1 pt |
Being creative (everyone is, this is just to make it 5 points) | 1 pt |
TOTAL | 5 pts |
DUE: Monday, February 28 for a demo in class.
Assignment 5: Implications of Watson
To wrap up our exploration of this historic week in CS with the IBM Watson/Jeopardy! challenge, I would like you to reflect on your understanding of this milestone and its significance. Regardless of whether or not Watson beats the human game players, the achievement of the computer scientists who created this system is extraordinary. Here is a bibliography of articles and videos about the Watson system and the Jeopardy! challenge of a computer system that does artificial intelligence:
- PBS NOVA documentary: Smartest Machine on Earth
- IBM website: IBM Watson
- NY Times Magazine article: What Is I.B.M.’s Watson?
- Atlantic Monthly article: Mind vs. Machine
- WIRED Magazine article: What’s It Mean to Be Human, Anyway?
Read or watch any or all of these, and then write a short paper answering the following questions. Each question should be answered in a well-constructed and concisely written paragraph, and you should clearly and completely answer each question. (Those of you who attended the event at the UW may find some of the questions familiar.)
- Who was Alan Turing and what is the Turing Test?
- What does it mean to be “human,” especially in conversation?
- Name at least three factors that make the Jeopardy! challenge difficult for a computer, and for each factor explain why.
- How does Watson work? Describe at least three principles of its design.
- Why is a system like Watson, which can answer general natural language questions, a much more significant achievement than creating a search engine like Google?
- Explain why both serious computational power and finely tuned algorithms are necessary for Watson.
- Watson is considered the latest “Grand Challenge” in science and engineering. What constitutes a “Grand Challenge,” and name at least three previous ones that have been achieved. What might be the next one?
- What are some of the moral, ethical, and societal implications of Watson, assuming this technology makes its way into the mainstream at some point in the near future?
GRADING (Homework) | |
---|---|
Each questions answered satisfactorily | 2 pts each |
TOTAL | 16 pts |
DUE: Friday, February 18 on paper in class.
Assignment 4: The Handshake Problem
Following our exercise in class about finding a method to solve the Handshake Problem, I’d like you to reflect on what you discovered in the process. First read this short article about Computational Thinking: “Computational Thinking,” Jeannette M. Wing, Communications of the ACM, March 2006, Vol. 49, No. 3. Then write a short note answering the following questions:
- Why is this kind of problem (the handshake counting) important?
- Where might that kind of problem come up in the world?
- How could your solution be used in other domains (e.g., carpentry, cooking, fashion) ?
- (extra) Graph the solution to the handshake problem: y = x(x-1)/2. Prove, mathematically, that ? [n + (n-1) + (n-2) … 1] = n(n-1)/2.
Here are the slides from class: Computational Thinking
GRADING (Homework) | |
---|---|
Questions answered | 1 pt each |
Solution proof | 1 pt extra credit |
TOTAL | 3 pts |
DUE: Thursday, February 10 on paper in class.
Assignment 3: Diversity in Binary
To celebrate Diversity Week at Roosevelt and to practice what you learned about binary counting on Friday, let’s combine the two themes. Write out the place of your birth on a piece of paper. Use the city and state if you were born in the United States or the city and country if you were born outside of the US. Then, using our 5 bit alphabet code, translate that text into binary and write the binary version on a separate piece of paper. (For an extra challenge, you can encode your birthplace in real 8-bit ASCII code!) Then we will exchange codes and you will decode someone else’s birthplace and print the translation on that piece of paper. When everyone is done, we’ll have a Binary Diversity Gallery to display. Here are some useful files you can download:
- Binary counting explanation: Binary Counting
- 5-bit binary alphabet: Binary Alphabet
- ASCII character set codes: ASCII Code
- Roosevelt Riders in binary: Riders Binary
- Davidson birthplace in binary: Davidson Birthplace
GRADING (Classwork) | |
---|---|
Your birthplace encoded | 1 pt |
Someone else’s birthplace decoded | 1 pt |
TOTAL | 2 pts |
DUE: Tuesday, February 8 on paper in class.
Assignment 2: UW CSE Research Report
Read about all of the different research projects and areas of investigation in the UW Computer Science and Engineering program at this link: UW CSE Research. Pick at least five specific projects that you find interesting, and read about the research efforts. Make notes of each one in your journal. Include the name of the project, a URL for reference, and a summary sentence about the research work. Then write a short report about the five projects. (I think that the Mobile and Ubiquitous Systems, known as UbiComp, may be of particular interest and relevance to our upcoming Arduino projects, but feel free to peruse all areas.) Your report should summarize each project, in your own words, and say why it interests you or what you find intriguing about it. Also state why you think, to the best of your understanding, the research area is significant in computer science. One concise paragraph for each project is sufficient. The purpose of this assignment is two-fold:
- To give you some insight into what the field of computer science is all about, in a research context.
- To give me an idea of what projects you think are most interesting so that I can try to arrange guest speakers to come to our class and talk to us about the work.
GRADING (Homework) | |
---|---|
Five projects cited | 1 pt each |
Summary paragraph completed for each | 2 pts each |
TOTAL | 15 pts |
DUE: Monday, February 7 on paper in class.
Assignment 1: Day 1 Questions
Please turn in the sheet with your answers to the two questions from Day 1:
- Why did you take this course? What do you hope to gain from it?
- What is your definition of computer science? What do you think the field covers?
GRADING (Classwork) | |
---|---|
Each question answered | 1 pt each |
TOTAL | 2 pts |
DUE: Tuesday, February 1 in class.
Assignment 0: Student Info Survey
Please fill out an online survey with some information about yourself for me. You can find a link to the survey in the menu above on this site: Info | Student Info Survey.
GRADING (Classwork) | |
---|---|
Survey completed | 1 pt |
DUE: Tuesday, February 1 online.