Digital/Analog Input + Arduino
Difference between Digital and Analog Inputs/Outputs:
1. Digital Input: Only have two states (ON or OFF). Can be connected to digital pins on Arduino. E.g. push buttons, switches, etc.
2. Digital Output: Can be connected to digital pins on Arduino. E.g. LED, Speaker, Motor, etc.
3. Analog Input: These can vary between multiple states. Can be connected to analog pins on Arduino. E.g. potentiometer, sensors, etc.
4. Analog Output: Same as digital outputs but vary between multiple states instead of just ON and OFF.
Labs
1. Digital Input + Output
This is the first circuit that I created that uses digital code to define its input and output parameters. The lab also helped me familiarize myself with the pin structure of Arduino Nano 33 IoT. First, the microcontroller is mounted atop the breadboard at the center. I powered it up with a USB connection to my laptop and then connected the positive and negative ends on both sides of the breadboard. The input in this particular circuit is the push button, which is connected to digital Input pin 2 of Arduino. This end is connected to the ground via a 10k-ohm resistor. The other side is connected to the positive end. The outputs in this circuit are 2 LEDs (yellow and red) which are connected to digital pins 3 and 4 of the microcontroller via 220-ohm resistors. This completes the physical circuit.
In Arduino IDE I add/install the board and select the correct port to complete the connection with the microcontroller. After that, I use the given code and upload it to the microcontroller. Once done the circuit should start working as expected. Please find a video of my circuit below:
Question: Is there any easy way to remember the Arduino pins (and what they are supposed to do)?
2. Analog Input
In this lab, we used an analog input instead of a digital one. A variable resistor (resistor with a potentiometer) was used as the analog input in this particular circuit. The middle leg of the potentiometer is connected to analog input pin 0 of the microcontroller. One other leg is connected to the positive end and the remaining one to the ground. The output was a red LED. The circuit was then programmed (as explained in the above lab) to dim or increase the brightness of the LED based on our turning of the potentiometer. Please find a video of my circuit below:
Question: Can we connect both analog and digital inputs in a circuit (and maybe to each other, For e.g. first a push button and then the potentiometer)?
3. Sensor Change Detection
In the last lab, we tried to detect changes in the sensor readings of a circuit. In the first part, we used a push button as the (digital) input to detect the high and low states.
A. Check if the button is pressed or not
B. Count button presses
C. Check how long the button was pressed
In the second part, we used an FSR (Force Sensitive Resistor) as the analog input to detect peaks (when certain sensor thresholds were crossed).
D. Sensor crossing threshold
E. Detecting Peaks
F. Removing noise (local peaks)
Comments