top of page

Lab 3:Arduino and digital i/o

Part 1: digital I/O circuit with two input switches and output LEDs

I began making my digital I/O circuit by starting with 3 LEDs and one pull up resistor as shown in the video to the far left. Using jumper cables, I connected 3 of my 220 Ohm resistors to 3 LEDS and to digital pins 5, 6, and 7 on my Arduino. I placed the anodes of my LEDs next to the resistors, and their cathodes to ground. I then connected a momentary switch to digital pin 3, and added my 10k Ohm pull up resistor (one end of the resistor placed next to the right lead from my switch, and one end in the positive rail on  the breadboard). I was able to turn all 3 LEDS on by pushing the button. When using a pull up resistor, the system is in a default high state until the button / switch is pressed, triggering a low state that signals the LED's high / "on" state as instructed in my code.

 

I then tested my pull down resistor by adding a second switch into pin 2 and another 10k Ohm resistor. One end of my resistor was placed next to the right lead of my second momentary switch, and the other end was placed in ground. Unlike a pull up system, the pull down system is in a default low state, meaning that pushing the button triggers the high state. I tested my pull down resistor in my code by making all 3 LED's stay in a high state unless the button is pushed, putting the system in a high state and thus putting all my LEDs in a low / "off" state. 

Lastly, I successfully incorporated both my pull up and pull down buttons into one circuit using the code below. My code signals my three LEDs to twinkle (or turn on with a delay of 100) when the pull up button on the right is pressed, and it turns all three LEDs on when the pull down button on the left is pressed (I decided to change my code after testing the pull down resistor so that the LEDs would not be in a constant high state). The states of my LEDs and buttons for the pull-up / pull-down resistors are also described in my comments inside of the code.  

20210210_161959_edited_edited.jpg

schematic: digital I/O circuit with two input switches and output LEDs

Part 2:  A DIY switch integrated into a digital I/O circuit

DIY clip switch and momentary switch working in digital i/o circuit

20210210_161959_edited_edited_edited.jpg

My first attempt at the DIY switch was a chip clip attached to pieces of foil containing the jumper cables from the pre-existing switch. I later realized that this idea wasn't working because my 9v battery died and because my jumper cables weren't positioned correctly. I ended up using a power supply to my laptop.

I moved on to using a different type of chip clip ( the locking green one pictured in the center). I began by taking out the old button switch and adding 2 new jumper cables -- one behind the cable connected to digital pin 2, and another in front of the cable connected to the 5v power supply. I also decided to move the cable connected to digital pin 2 and the new jumper cable to the right side of my breadboard for an easier connection to the 10k resistor. I then taped the ends of the new cables to opposing sides of my clip and covered each side in a small piece of foil. When the clip is closed, the conductive materials on both sides connect, allowing the LEDs to turn on. Since I directly substituted my DIY switch for one of the original switches from part 1, the code and schematic diagram of my circuit remain the same for part 2.

Part 3: Creative Enclosure

DIY digital i/o circuit working inside of creative enclosure

My creative enclosure was made by scoring a piece of cardboard to create the perfect sized box. I measured the size of my breadboard and the arduino to decide the width and height of the box, but I decided to leave some extra length and openings on the sides for additional future components. I also wanted the sides to be open because my 9v battery died, and I needed to allow room to connect the power supply to my computer. I created two flaps and two slits along on edge, which allow me to fasten the box shut, and to easily access my arduino. The two small holes on the top were intended to show the LEDs, to provide access to my other button, and to allow the cables for my DIY switch to come through the top. The DIY switch is secured onto the top with double sided tape. 

bottom of page