Introduction: Lab 1 for CSCI 1200

This is an example of a light switch using the Arduino Uno. In this lab, I created a program that will turn a specific LED when a specific button is pressed using two LED's and two Push Buttons. This lab has been broken into a few simple steps followed by a quick guide on how you can get your project to work if you're experiencing issues. The last step is an attachment of the code required to run this executable.

Step 1: Step 1: Add the LEDs

1. Place an LED of any color onto the bread board.

2. Connect one end of the Jumper Wire to the bottom lead (-) on the bread board, and the other to the ground rail.

3. Connect one end of a 220 (ohm) Resistor from the bottom lead (+) on the bread board and the other end into Pin 13 on the Arduino.

4. Place a second LED, preferably of a different color, onto the bread board.

5. Repeat steps 1-3, this time connecting the second 220 (Ohm) Resistor to Pin12 on the Arduino Uno.

6. Finally, connect a Jumper Wire from the ground rail to the GND (ground) Pin on the Arduino.

Step 2: Step 2: Add the Push Buttons

1. Place the push button in columns "E" and "F" on the breadboard. This method is used to separate the rows to make two different sections.

2. Place a Jumper Wire to connect the left side of the button to the positive power rail.

3. Place another 220 (Ohms) Resistor to the right side of the button and connect it to the ground rail.

4. Place another Jumper Wire on the right side of the button in column "F" on the breadboard. Connect this wire to Pin 3 on the Arduino.

5. Repeat steps 1-4 to connect the second button and connect the Jumper Wire in column "F" to Pin 2 on the Arduino.

6. Finally, place a Jumper Wire at the top of the power rail and connect the other end to the 5v Pin on the Arduino.

Step 3: Step 3: Common Issues With the LEDs and Buttons

LED's Won't Turn On :

  • Make sure the LEDs were inserted correctly. They can only be powered in one direction. If the LEDs won't turn on, try reversing it. The long end is the positive (+) side and the shorter lead is the negative (-) side (which will need to be grounded).

LED's Too Dim:

  • Double check the resistor you used is a 220 (Ohm) resistor. If you use a larger resistor, the LED will dim because it's receiving less current.

LED Won't Turn Off:

  • Make sure you've wired the buttons correctly. The push button is a metal plate that connects the top and bottom wires. Your circuit must be between the top and bottom wires, otherwise, the circuit will always be connected causing the lights to remain on.

Step 4: Step 4: Code for Light Switch

Attached is the Lab1.ino which contains all the code for the light switch project on the Arduino Uno.

Attachments