User Tools

Site Tools


Lecture 12: Design of Support Structure for the Desktop Fan; Button Input

Checklist: What you need to bring for this lecture

  • Laptop
  • Sparkfun Tinker Kit or Sparkfun Inventor's kit
  • Digital multimeter
  • Miniature test clip adapters

Learning Objectives

After this lecture you should be able to

  • use a while loop in Arduino code
  • explain the behavior of pull-down and pull-up circuits for buttons
  • explain how normally open (NO) and normally closed (NC) switches (or buttons) function in a DC circuit
  • create a circuit for using a momentary button as a digital input
  • use a momentary button as a “wait-to-start” input


Videos and Lecture Slides

Button input for Arduino

Arduino Codes

Each of the following codes are designed to handle the input from a momentary button configured with a pull-down resistor.

  • button_status.ino is a simple sketch to indicate whether the button is currently pressed. Apart from displaying the button status, this program has little practical use.
  • button_wait_for_input.ino is a sketch that blocks execution until a button is pressed. This could code could be used as a wait-to-start button.
  • button_interrupt.ino demonstrates how to use an interrupt to detect when a button is pressed. This is the recommended strategy for using button input.
  • button_interrupt_count.ino is the same as button_interrupt.ino except that the total number of button presses since start-up is printed to the Serial Monitor.
lecture/lecture_12.txt · Last modified: 2020/01/08 14:55 by johnj