Week 3 Arduino Homework

Here are the videos for the Arduino exercises. I liked this week’s exercises because they were a little more challenging and got me thinking of ways of using arduino in real life.

Exercise 1: Digital Input

Exercise 2: Serial Monitor

For the Arduino circuit of my own, I made 2 arduino buttons turn the red led light on and off.I used tinkercad first and it was incredibly helpful.

Link to the public tinkercad circuit here:

Epic Wluff-Juttuli

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int buttonPinOff = 4;

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int buttonState2 = 0;

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
pinMode(buttonPinOff,INPUT_PULLUP);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
buttonState2 = digitalRead(buttonPinOff);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == LOW) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
if (buttonState2 == LOW){
digitalWrite(ledPin, LOW);
}

//else {
// turn LED off:
//digitalWrite(ledPin, LOW);
// }


}

Here is a link to the video of my code in action: https://vimeo.com/291401843

 

2 thoughts on “Week 3 Arduino Homework”

Comments are closed.