Arduino and Digital I/O

In this lab, we will learn about the Arduino prototyping environment and explore how to use the digital inputs and outputs of our microcontroller. We will integrate these into a project by building a custom switch and enclosure.

Overview of pull up/pull down circuit for the firs part of this lab

Overview of pull up/pull down circuit for the firs part of this lab

Digital I/O circuit

To begin, we worked through creating a pull-up and pull-down resistor for digital input switches that then control digital outputs via LEDs. This code can be viewed below.

For some reason, this wasn’t working. I double checked my code, checked all of my resistors, replaced my switches with jumper cables, and nothing. I straightened out the pins of the switches to better fit in the breadboard, still nothing. This had just worked the other day, so why not now? I took a little break because I was frustrated and decided to come back to it.

Top switch with straight pins, bottom with still-bent pins

Top switch with straight pins, bottom with still-bent pins

Breadboard with all wires connected, but still not responding

Breadboard with all wires connected, but still not responding

Schematic for digital input/output switches with Arduino

Schematic for digital input/output switches with Arduino

DIY Switch

After working with this digital input and output, I then swapped out the buttons for a physical switch. I changed around my circuit and moved it to the mini breadboard to fit into a smaller space as well as ensuring each LED is independent from each other as my switch will require a piece of conductive copper tape to touch and therefore light each one separately.

My plan for this switch will be a piece of cardboard that, when turned in the direction of each LED, will light the corresponding LED as a sort of indicator. I connected copper tape to jumper wires and cardboard to achieve this.

Carboard with wires attached to copper tape

Carboard with wires attached to copper tape

Circuit created on mini breadboard attached to Arduino

Circuit created on mini breadboard attached to Arduino

I once again ran into troubles with this part, as I had to reorient myself with the layout of the mini breadboard. I double-checked my code and realized that this would be done incredibly simply with strictly analog input, which should make the digital portion easy. The code can be viewed below.

Assembled DIY switch

Assembled DIY switch

Creative Enclosure

For this portion, I worked on turning my DIY switch into a type of enclosure. My first step was to punch through the LEDs. This required attaching the LED leads to female jumper wires and securing with electrical tape to add length.

The front with LEDs punched through

The front with LEDs punched through

The back wiring of my soon-to-be-enclosure

The back wiring of my soon-to-be-enclosure

I made sure I knew which wire went to which lead and which thing and then organized the back by securing with electrical tape. Things were beginning to shape up.

After I got everything secured and attached to the breadboard and Arduino again, I was able to close the other ends of the box. I added the phrase “How do I feel today?” so that this could be a visual indicator of my daily mood. The finished enclosure is pictured below.

Finished enclosure to represent my mood for the day

Finished enclosure to represent my mood for the day