In this lab, we created a simple circuit to control LEDs simulating a spaceship interface.
Step 1: Setting up the circuit
We wired up the breadboard with two red LEDs and one green LED, wired in series through 220 ohm resistors. Next, we placed a switch on the breadboard to control the operation of pin 2 on the Arduino. We used a 10k-ohm resistor for the switch which connected to ground when the switch was open and read “low” when there is no voltage coming through the switch.
Step 2: Writing the code
We wrote a short program to control our spaceship LEDs. First we setup pins 3-5 to control output, and pin 2 to accept input. Then, in the main loop of our program we created a condition to check for low voltage output on the switch (input 2). If low-voltage was detected, the LEDs would flash in the proper sequence.
Step 3: Testing the program
We connected the Arduino to the computer and launched our program in the Arduino software. When we press the button on the breadboard, our lights flash in sequence just as we intended.
Step 4: Adding a temperature sensor
We added a temperature sensor in place of the switch. Now, when the temperature sensor is touched, the LEDs will flash in sequence. This is also known as the Arduino Love-o-meter project.