Homework 10
Due: 2023/11/15 by 1PM
Programming (10 points)
Another Clock
Well. . . sort of.
This week, we are going to use our Arduinos to create a physical, light-based, time-keeping device.
This is similar to HW04, but different.
Since the Arduino resets every time it’s shut off, and we don’t have it connected to the internet yet, it isn’t capable of knowing exactly what time it is. Because of this, there are no functions for getting the current hour, minute or second, just millis()
, which tells us how many milliseconds have elapsed since the Arduino board began running the current program.
In this assignment we are going to use millis()
to calculate the number of seconds that have elapsed since our program began running, and display that using LEDs. Since we will have a finite number of LEDs to do this, we will use “clock” seconds, meaning, numbers between 0 and 59, not 0 to infinity.
There are many ways to do this using the analog and digital output functions from the Arduino:
- We could use one LED per 10 units of time, so 20 seconds would be represented by 2 lit LEDs, 30 seconds by 3 LEDs, etc.
- Numbers between 0 and 59 can be represented using 6 binary digits, or, bits.
- Numbers between 0 and 59 can be mapped to numbers between 0 and 255 and used as parameters to the
analogWrite()
function.
Requirements:
- Visually display the number of elapsed seconds in the range [0 - 59]. Feel free to include extra LEDs for minutes, hours or milliseconds.
- Use a minimum of 6 LEDs.
- Make it legible. It should be easy to see that time is passing by looking at the LEDs. One LED that fades from fully OFF to fully ON over a minute is probably legible. One LED that fades from fully OFF to fully ON over an hour is not legible.
- Make it personal. Make it interesting.
- Using
analogWrite()
is NOT a requirement.
Tips:
The first challenge is to figure out a way to turn millis()
into wall seconds.
Every time the loop()
function runs it should use millis()
to calculate values for the 6 LEDs.
millis()
returns a number that grows from 0 to infinity, while the number of seconds is a number that cycles from 0 to 59 and then back to 0 again. Sounds like a modulus operation.
Just remember that 1 second is equal to 1000 milliseconds.
These videos with week 10 content should help.
Each LED will need its own resistor. 100Ω is a good value.
Resistors and LEDs can be connected directly to the Arduino, without having to use wires. The lab has cables and wire-strippers to make more jumper cables.
The long lines on our breadboards can be used to distribute ground or 3V throughout the board.
Submission and Grading:
There’s no template to clone for this one. We’ll just start a project named HW10 through the Arduino IDE and then push its folder to our GitHub account (like in this video).
Include a README with:
- Description of how you encoded seconds into lights.
- A schematic drawing of your circuit.
Use Brightspace to submit a link to your repository and a video of your project working. The video should be 15 to 30 seconds long and you can upload the file to Brightspace or host it somewhere else and submit a link.
The following guide will be used for grading:
Task | Points |
---|---|
README file with diagram | 2 points |
Follow assignment instructions | 2 points |
Implementation | 2 points |
Thoughtfulness | 2 points |
Craft | 2 points |
Implementation: work shows evidence of understanding programming concepts and you are fully using them to express your ideas.
Thoughtfulness: project demonstrates your personality and it’s not a straightforward re-implementation of someone else’s idea.
Craft: code and results show care and consideration for presentation and professionalism, and work doesn’t look like it was rushed.
Read & Respond (5 points)
Other codes and other technologies
Read and write a 200-word response to the following:
Just to avoid confusion, the sections to read are called:
- Introduction: The New Jim Code (pg 9)
- Everyday Coding (pg 10)
- Move Slower … (pg 15)
- Tailoring: Targeting (pg 20)
- Race as Technology (pg 33)
As always, your response should be personal, meaning that you should be expressing your views and opinions about the text and not just summarizing it. You can use the following rubric to guide your response:
- Short summary: in one or two phrases, what is the book about?
- Memorable quote: Is there a phrase that stands out?
- Did you learn something new? What?
- What do you agree or disagree with? Why?
- Did the text remind you of any other texts we’ve read so far?
- How is the text related to programming?
- Was there anything in the text that surprised you? What? Why?
Please submit your response via Brightspace.
Alternatively, you may create a reading.md
file in your HW10 repo and write your response in markdown. Just make sure to submit a link to the file using Brightspace.