Teacher Goal

By the end of this lesson students should have mastered connecting electronic components to the Arduino via a solderless prototyping board, and how to program Arduino digital pins to turn light-emitting diodes (LEDs) on and off.

Hints:

  • Use a rubber band to attach the Arduino Uno to one end of the prototyping board. This reduces the chances of wires being pulled free from their connections and makes for a better-looking experiment platform.
  • Encourage students to use different colored jumper wires. Some may be inclined to make all jumpers the same. This makes examining work for errors challenging.
  • Be aware that odds are at least one student is color blind.
  • Make sure the resistors are 220 ohm (red-red-brown). Any resistance from 150 ohms through 500 ohms will work but 220 gives good brightness while minimizing chances of accidentally burning out an LED.
  • Remember most digital multimeters are now capable of testing LEDs, allowing you a way to identify the anode (positive) and cathode (negative).
  • We teach the wire connected to the anode is longer than the wire connected to the cathode. This is usually the case. Sometimes students will cut one of the wires, making this test unreliable. And, some diodes come with wires that are the same length. See the Help articles about diodes for information about how to identify the anode of one of these diodes.

Wiring

Student solderless breadboard should look like this.

 

 Activities

The first activity is to make a pair of light-emitting diodes blink alternately. This should look like this:

 

 The Thermometer activity should look like this:

 

Common Student Errors

  1. Connections to GND. Each of the LEDs should have its cathode lead (the short wire) plugged into the blue striped strip on the breadboard. Plus, a jumper should connect that strip to one of the three GND pins of the Arduino. Students often forget this jumper, put it in the wrong strip, or connect it to some pin on the Arduino other than GND.
  2. Students often confuse the Arduino programming statements pinMode() and digitalWrite(). The former is used to set a digital pin to INPUT or OUTPUT; the latter to turn a pin on (HIGH) or off (LOW).
  3. Students often forget to initialize digital pins for OUTPUT. Make sure each pin being used has its mode set to OUTPUT.
  4. Sometimes a student will forget to provide a delay() after an LED has its write status change, causing an LED to appear never to turn off or never to appear to turn on, even though the student code has the correct digitalWrite() statements. An LED attached to pin 9 will never appear to be off in the following code example:

1 void setup(){
2   pinMode(9, OUTPUT);  // LED attached to this pin
3 }

4 void loop(){
5   digitalWrite(9, HIGH);  // turn LED on
6   delay(500);
7   digitalWrite(9, LOW);   // turn LED off
8 }

Remember the loop() method runs over and over. So, while it is true the LED is being turned off in line 8 it is being turned back on almost instantly in line 5 when loop() runs again.