Week 3 HW Exercises

Hey guys!

This week’s homework was definitely a challenge for me. The exercises went well up until the part where I had to create my own sketch. At this point it seems like there might be technical difficulties with my board or faulty wiring, since I still can’t get it to work after many hours. Here’s the latest iteration of my code to control an LED with 2 buttons (ON/OFF) and a picture of my circuit board.

// constants won't change. They're used here to set pin numbers:
const int button1 = 5; // the number of the 1st button pin for on
const int button2 = 3; // number of 2nd button pin for off
const int ledPin = 13; // the number of the LED pin

// variables will change:
int button1State = 0; // variable for reading the pushbutton status
int button2State = 0; // variable for button 2 state

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize button 1 pin as an input:
pinMode(button1, INPUT_PULLUP);
//initilize button 2 as an input
pinMode(button2, INPUT_PULLUP);

void loop() {
// read the state of the button 1 value:
button1State = digitalRead(button1);
//read state of button 2 value:
button2State = digitalRead(button2);

// check if button 1 is pressed. If it is, the button1State is HIGH and button2state is low:
if (button1State == LOW) {
// turn LED on:
digitalWrite(ledPin, HIGH);

//check if button 2 is pressed;

if (button2State == LOW) {
//turn LED off:
digitalWrite(ledPin, LOW);


Here’s the instagram link for the digital input and serial monitor lessons.