Week 5- Circuit 5
- Audrey Schank

- Nov 24, 2024
- 2 min read
This week we were able to select our own challenge for our adventure in making. I have really been struggling with this each week, so I went with the next challenge in the Arduino Uno Guide, Circuit 5. This circuit required the use of 2 push buttons, 1 LED, 2 10K resistors, 1 330 resistor, and 7 jumper wires. This circuit involved the use of inputs and the book explains that push buttons are one of the most common inputs.
I am very happy to share that I was able to set-up this circuit on the Arduino and breadboard and get the code in correctly and the LED actually worked when I pushed the buttons! This is a very BIG accomplishment for me! It did take me multiple tries to get it working, but I kept at it and didn't give up. First, I was getting multiple errors on the code, so I went through it and looked up examples online. Once I had that working properly without errors, the LED was lighting up, but not when I pushed the button. Like in past weeks, I double checked the LED and I actually had it in correctly this time. Then I checked that all the wires were securely connected and checked the resistors. One of my resistors was turned around from what the diagram showed, so I fixed that. This is when the push buttons started working!
Some real-world examples of this circuit using push buttons would be video game controllers. I haven't played video games in ages, but I remember having sore thumbs when I was a child from playing Super Mario Bros. for hours! I wonder if remote controls would also be considered an example of this type of circuit? Or maybe other things with buttons like microwaves, elevators, or keypads on door locks, etc.?
Video of Working Push Button
Photo of Breadboard Set-up

Electronic Diagram

Code
const int button1Pin = 2; // pushbutton 1 pin const int button2Pin = 3; // pushbutton 2 pin const int ledPin = 13; // LED pin void setup() { // Set up the pushbutton pins to be an input: pinMode(button1Pin, INPUT); pinMode(button2Pin, INPUT); // Set up the LED pin to be an output: pinMode(ledPin, OUTPUT); } void loop() { int button1State, button2State; // variables to hold the pushbutton states button1State = digitalRead(button1Pin); button2State = digitalRead(button2Pin); if (((button1State == LOW) || (button2State == LOW)) // if we're pushing button 1 OR button 2 && ! // AND we're NOT ((button1State == LOW) && (button2State == LOW))) // pushing button 1 AND button 2 // then... { digitalWrite(ledPin, HIGH); // turn the LED on } else { digitalWrite(ledPin, LOW); // turn the LED off } }


Comments