UBC Logo

Worksheet Exercises

  • controlLEDs

Task

We are to control the state of three LEDs based on the values of the two switches according to the following table:

SWITCH0SWITCH1 LED0LED1LED2
OFFOFF OFFOFFOFF
ONOFF ONOFFOFF
OFFON OFFONOFF
ONON OFFOFFON
arduino hardware

Hardware Setup

We need two switches and three LEDs. For the switches, we can use either DIP switches, or push-buttons. The following schematic uses DIP switches.

hardware layout Fritzing schematic: apsc160_sim1.fzz

ComponentCount
Full Size Breadboard1
Slide DIP Switch (2 or 4 positions)1
or Tactile Switch2
LEDs (5 mm Round, Various)3
220 Ohm Resistor3
10 kOhm Resistor2


Software Implementation

controlLEDs.ino