Fraser Comp Sci ClubMeeting 03 Challenges
Thu Oct 29 · 11:05 AM · Rm 183 · Open meeting, no sign up needed

Arduino!!

Write code that controls real things. Never coded? Start at Blink. Built stuff before? Skip to the challenges.

Meet the Uno

A tiny computer that runs one program forever. Its pins can turn things on and off and read buttons and sensors.

  • Pins 2 to 13: on or off. The ones with a ~ can also dim.
  • A0 to A5: read a knob or sensor as 0 to 1023.
  • 5V and GND: power for your breadboard.
Arduino Uno board

Don't fry it!!

  • Every LED still needs a resistor.
  • Never plug a motor straight into a pin.
  • Unplug USB before rewiring.

Blink

The "hello world" of hardware. The Uno has an LED built in, so this works with nothing plugged in.

LED
Resistor
  1. Plug in the Uno. Pick Tools → Board → Arduino Uno, then Tools → Port.
  2. Paste the code and hit Upload (→). The little L LED blinks.
  3. Change 500 to 100 and upload again.
  4. Your own LED: pin 13 → 220Ω → long leg, short leg → GND.
void setup() {
  pinMode(13, OUTPUT);     // runs once
}

void loop() {              // runs forever
  digitalWrite(13, HIGH);  // on
  delay(500);              // wait 500 ms
  digitalWrite(13, LOW);   // off
  delay(500);
}

Challenges

Finished the projects, or already know your stuff? No code given. Show an exec when yours works!

Easy Traffic light

Red, yellow, green LEDs that cycle. Add a crosswalk button.

Easy Toggle

Press once for on, again for off. Harder than it sounds!

Medium Reaction timer

LED turns on at a random time. Press fast and print your time in ms.

Medium No delay()

Blink 3 LEDs at 3 different speeds at once. Hint: millis().

Hard Simon says

4 LEDs, 4 buttons, a pattern that grows every round.

Boss Bare metal

Blink pin 13 with PORTB instead of digitalWrite. How much faster is it?

← All meetings

Photos from Wikimedia Commons: Uno: MakeMagazinDE, CC BY-SA 4.0 · LED: oomlout, CC BY-SA 2.0 · resistor: oomlout, CC BY-SA 2.0 · button: Scwerllguy, CC BY-SA 3.0 · knob: Iainf, CC BY 2.5 · servo: Suyash Dwivedi, CC BY-SA 4.0 · motor: Monoklon, CC BY-SA 3.0 · transistor: MarkMossGH, CC0 · diode: oomlout, CC BY-SA 2.0