Arduino Week 3 Exercises


This week’s Arduino exercises were definitely more challenging than the previous week’s, especially the final exercise of creating your own circuit function in Arduino. It took me a while to understand the coding syntax and the logical progression, but I came away with a deeper understanding of Arduino. Like last week, I still struggled occasionally with correctly inputing wires, resistors, and LEDs. With that said, I found that drawing out circuits in TinkerCad was super helpful for brainstorming and using it as a reference/second eye for the actual circuitry on the bread board.

Here are recordings of the exercises:

Digital Input:

Serial Monitor: 

LED on/off with two buttons:

And here is the code & TinkerCad circuit map:

// constants won’t change. They’re used here to set pin numbers:
const int ledPin = 13; // the number of the LED pin
const int buttonPin1 = 8; // the number of the on pushbutton pin
const int buttonPin2 = 7; // the number of the off pushbutton pin

// variables will change:
int buttonState1 = 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(buttonPin1, INPUT_PULLUP); //enable pull-up resistors
pinMode(buttonPin2, INPUT_PULLUP);

void loop() {
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);

if (buttonState1 == LOW) {
digitalWrite(ledPin, HIGH); // turn LED OFF
} else if (buttonState2 == LOW) {
digitalWrite(ledPin, LOW); // turn LED ON