Skip to content

11. Output Devices

This week: Exploring output devices using a homemade board.

Group Assignment

Measuring the power consumption of an output device. Here we are running a DC Motor using a power supply set to 5V and showing the Amperage draw:

Reading the Power Consumption of a DC Motor with a Power Supply set to 5V by me on Vimeo.

Here we are running a DC Motor off a 9V battery through a Multimeter to see the Amperage draw (as shown in a messy and then slightly cleaner environment):

Reading the Power Consumption of a DC Motor with Multimeter at the chaos table by me on Vimeo.

Reading the Power Consumption of a DC Motor with Multimeter by me on Vimeo.

Individual Assignment

Add an output device to a microcontroller board you’ve designed, and program it to do something. So I built off what I did in the Embedded Programming assignment programming a button and an LED on a board run off the ATTiny44 microcontroller, programmed in the Arduino IDE:

Embedded Programming Demo by me on Vimeo.

Code Example

Arduino Push Button LED Code:

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 3;     // the number of the pushbutton pin
const int ledPin =  7;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }

Last update: March 31, 2022