Why are microcontrollers helpful?

"Microcontrollers allow you to change the behavior of the circuit without changing the circuit itself?

Code derived from: https://itp.nyu.edu/physcomp/labs/labs-arduino-digital-and-analog/lab-sensor-change-detection/

LAB: Digital Input and Output with an Arduino

Image 1: Confusion among cables

Image 1: Confusion among cables

Confusion ran rampant at the beginning of this lab. I could not get the port to be recognized in the tools menu of the arduino IDE. Eventually after trying many different configurations and different wiring solutions I found out that the USB to micro USB shown at the top of image 1 was not the correct adapter. The adapter provided to us in class, the USB to micro-usb on the bottom of the image established the correct connection.

Q: What is wrong with above adapter. It provided power to the Arduino allowing it to operate as expected but was not recognized by the Arduino IDE. How is it different from the cord below?

Image 2: Using digital input to turn on LEDs

Image 2: Using digital input to turn on LEDs

The code above checks the digital input at pin 2 on the Arduino to see if it has LOW or HIGH input. In this case using a switch LOW corresponds to off or not being pushed and HIGH corresponds to pushed or on.

Image 3: Breadboard executing image 2 code attached

Image 3: Breadboard executing image 2 code attached

Lab: Analog Input

Video 1: Breadboard using analog input

Video 1: Breadboard using analog input

Video 2: Serial monitor detecting analog and digital input states of a switch (digital), pot(analog), and photocell(analog)

Video 2: Serial monitor detecting analog and digital input states of a switch (digital), pot(analog), and photocell(analog)

If you play 1 and 2 simultaneously, you will see that using the serial monitor we can periodically detect the state of the pot, switch and photocell.

Q: What exactly do the serial numbers of the input pins mean? Are they absolute numbers or relative ie do they correspond to the start state?

Lab: Sensor Change Detection

Screen Shot 2021-09-26 at 5.58.56 PM.png

Using the same breadboard set up with different code we can detect the number of times the switch is pressed, the length of a button hold as well as when the pot passes a certain threshold and when it hits a peak while at an activity above the threshold we set.

Image 4: Code detecting when the pot crosses threshold of 500

Image 4: Code detecting when the pot crosses threshold of 500

Code detecting the length of a button hold

Code detecting the length of a button hold