Class 3

Wednesday, Jan. 23, 2019

  • go over Homework 2 (individual demos to instructor and TA)
  • submit code via email
  • address common problems/misconceptions

Format (and sample text) of comment block at the top of your code for handing in:

 * Homework 2
 * Andrew Carnegie (acarnegi)
 * 1 hour 25 minutes
 * Collaboration: Ada Lovelace helped me understand
 * variables and we worked on the code together.
 * Challenge: I tried to write my own function but
 * it did not go as planned. It took me an extra hour!
 * I was held up with bracket trouble the whole time, 
 * it seems.
 * Next time: I'll start by writing comments or pseudo-code
 * before trying to write the actual code. I think this
 * will reduce my getting tangled around the code
 * structure.
 * Summary: The code below blinks three LEDs according
 * to a pre-defined pattern.
 * Inputs: none
 * Outputs: 3 LEDs

The file name should be andrewid-homework-2.ino. Email to with subject “homework 2.”

  • maintaining sufficient resistance between power and ground
    • V=IR
  • learning more C:
    • variables to name numbers (int and const int types)
    • comments to explain thinking and plan out code
    • if...else to make logical branches
    • intro comment section at the head
  • wiring inputs!
    • analogRead and a potentiometer
      • live data via Serial feedback, plus Serial Plotter
    • wiring a switch or button as an input
      • use a pull-down resistor to avoid an ambiguous input
  • homework preview