Categories
Atlas Object

Lab 2: Digital I/O

Sparks were flying in this one.

Circuit with 2 LED’s and a Pixel Strip

For our second lab in ATLAS Object, we practiced programing our Arduino boards to control more complicated circuits.

Part 1: Two LED circuit, twice as lit as before!

For part one of this lab we were tasked to make an LED circuit with two LED’s and two switches to give two unique outputs.

Before I began making the circuit, I first drew a circuit diagram schematic. Since we were using the Arduino’s input and output pins, there were multiple sections to this circuit.

The next step was to find the proper resistors for the LED’s. I decided to use one green and one blue LED. I calculated the resistance value using the supply voltage, forward voltage, and the forward current.

My calculations

After finishing the resistor calculations, I drew the circuit diagram. I also included two 1K pulldown resistors for the digital inputs.

Circuit diagram.

Next it was time to actually build the circuit. I built the circuit as it was drawn in the diagram.

My 2 LED circuit

But nothing happened when I pressed the switches. My hardware engineering may have been done but now it was time to make the software in the Arduino IDE. I wrote a program that would tell the output pins connected to each LED to turn on if a corresponding input pin measured a high value and off if it reads low. This “high value” would be read if a switch was turned on completing the circuit from the 3V3 pin to the input pin. After a few trial and error attempts, I got the LEDs to turn on when their respective switch was pressed. I was feeling a little “tinkerish” so I decided to add an additional feature to the program. Rather than just turning both LEDs when both switches were pressed simultaneously, I programmed the Arduino to respond to both buttons being pressed with a cool LED sequence. This sequence repeats indefinitely until a button is pressed.

My final 2 LED circuit.

Part 2: The Strip

For the second part of our lab, we were tasked with programing an LED strip to respond to our switch presses. I decided to keep the LEDs on my board and add the strip to the existing circuit. I luckily had previously purchased a Raspberry Pi Nano kit that had a pre-soldered LED strip ready to go. All I needed to do was connect a few wires and write the program to operate the strip.

Writing the program was a learning experience. I had to learn how to use 3rd party libraries in order to operate the LED strip. I used the Adafruit NeoPixel library which worked very well with my generic light strip.

Since I kept my LEDs from the previous part in my circuit, adding in code to get outputs for the LED strip was easy. I made the LED strip turn blue when the switch to the blue LED was pressed and green when the green LED was pressed. To mix things up a bit, I programed my LED sequence that occurs when pressing both buttons to make the strip flash green and blue rapidly.

The code below definitely could have been made much shorter using while/for loops/recursive functions, but I was more concerned with getting my program working rather than making it easy to read and edit. I will definitely do a better job of this in the future.

My circuit with the LED strip

Part 3: Soldering

Soldering the breakout boards was the final part of the lab. I had a little bit of difficulty with soldering since I was not present for the last day of the lab. I was eventually able to get some help during after hours. The first step was to find the appropriate resistor for the two LEDs in series. Next I soldered a red LED, blue LED, a resistor, and two wires to the breakout board. Since I was able to use my existing circuit, connecting the wires to the correct pins was easy and required no coding.

My circuit with the breakout board.

Below is the video demonstrating the circuit working.

My breakout board circuit
Categories
Atlas Object

Object Lab: Basic Electronics

Brightening up the morning

We kicked off our Friday in lab with building circuits! For this lap we were tasked with building a both parallel and series circuits to light up two LEDs.

Building the series circuit

My series circuit diagram.

For this first circuit, I used an AC to DC adapter that connect to the bread-board, a voltage regulator, and a resistor with two LEDs. I also needed to add a push button switch.

Choosing the resistor value wasn’t extremely hard. I just used Ohm’s law to find the needed current for the particular color of LED.

After figuring out the resistor value, I got to actually building the circuit. I did not have too many issues making this circuit work other than the fact that I am still getting used to how small all of the components are. After a couple times trying to get wires to stay in their bread-board ports, I got it working.

My series circuit working.

Making the Parallel Circuit

Diagram of my parallel circuit

For the parallel circuit, I used the same components as the series circuits albeit with some extra wires, and an extra resistor. Unlike a series circuit, a parallel circuit will not drop voltage around the whole circuit with just a single resistor (and LED load). Because of this, the extra resistor was needed.

Having suffered through Physics 2 last year, I was able to remember how to build a parallel circuit. However, like my experience building the series circuit, I struggled to work with the small pieces. I found that the wires would easily slip out of the bread-board. Fortunately, I was able to get it working with only a few times cursing at my bread-board. The LED’s glowed brighter than the series circuit.

My working parallel circuit.