Arduinos!

Chandler Swift, UMD ACM

https://duluth.chandlerswift.com/arduino

What is an Arduino?

  • ATmega328p, ATmega32u4, …
  • Arduino.cc, SparkFun, Knockoffs, …
  • Programming community: ESP8266, ESP32, …
  • Focus on variety of I/O
  • Project Ideas: videos, blog

Raspberry Pi Comparison

Raspberry Pi Arduino Nano Arduino Pro Micro ESP8266
Cost $5-35+ $3-20 $3-20 $3-10
Power 2W (idle) 150mW(1) <250mW 75-750mW
Size, Speed, Connectivity, Reliability, Latency/Real-time, …

Where do I get parts?

Hardware Primer

  • Button (Pullup vs floating, debounce)
  • LED and current regulation
  • Breadboards:

Software Options

Sample Software


void setup() {
    // Setup goes here!
    pinMode(2, OUTPUT);
    pinMode(3, INPUT_PULLUP);

    // Initializing:
    for (int i = 0; i < 5; i++) {
        digitalWrite(2, HIGH);
        delay(500);
        digitalWrite(2, LOW);
        delay(500);
    }
}
void loop() {
    digitalWrite(2, !digitalRead(3));
}
(see also: blink.ino)

Equivalently…


#include <Arduino.h>
int main() {
    // Setup goes here!
    pinMode(2, OUTPUT);
    pinMode(3, INPUT_PULLUP);

    // Initializing:
    for (int i = 0; i < 5; i++) {
        digitalWrite(2, HIGH);
        delay(500);
        digitalWrite(2, LOW);
        delay(500);
    }

    while (true) (
        digitalWrite(2, !digitalRead(3));
    }
}

Our project

Pseudocode

Set up I/O pins, and while true:
  • Wait for start button press
  • Wait random time (checking for false presses)
  • Turn on "go" light
  • Wait for the first player to press
  • Light up their LED
Sample/Docs at github.com/ChandlerSwift/ProgrammingMBDemo

Note on breadboard organization: