9.Input devices¶
Group Assignment — Probing an Input Device¶
Overview¶
This week’s task was to probe an input device’s analog and digital signals using an oscilloscope. Under the guidance of Onik Babajanyan, we measured signals from input devices connected to our PCB.

Potentiometer (Analog Pin)¶
We applied voltage to the analog pin of a potentiometer. As we rotated it, the waveform rose and fell smoothly in proportion to the movement — a continuous, gradual change.
Photoresistor (Digital Pin)¶
Next we connected the oscilloscope to the digital pin of a photoresistor. Switching the light on and off produced sharp, immediate transitions — the signal jumping between high and low with no in-between.
Photoresistor (Analog Pin)¶
We repeated the light test on the analog pin instead, and this time the transitions were smooth, similar to the potentiometer behavior.
Analog signals change continuously, reflecting gradual shifts in input, while digital signals switch abruptly between two discrete states. Seeing both behaviors on the oscilloscope made the difference concrete rather than just theoretical.¶
Individual Assignment — Analog and Digital Signals¶
Overview¶
In this assignment, I explored the difference between analog and digital signals using a potentiometer connected to my custom PCB based on the Seeed XIAO RP2040.

What is an Analog Signal?¶
An analog signal is continuous and can take any value within a range.
In this experiment:
- Minimum position → ~0
- Middle position → ~500
- Maximum position → ~1023

What is a Digital Signal?¶
A digital signal has only two states:
- HIGH → ON
- LOW → OFF
The LED in this project works using digital control.

Microcontroller — Seeed XIAO RP2040¶
This microcontroller supports both analog and digital input/output.
Analog Pins¶
- A0 (GPIO 26)
- A1 (GPIO 27)
- A2 (GPIO 28)
- A3 (GPIO 29)
In this project, I used A0.

Analog to Digital Conversion¶
The potentiometer produces a voltage that is converted into digital values using an ADC (Analog to Digital Converter).
- 0V → 0
- ~1.65V → ~512
- 3.3V → 1023

—¶
Sensor Integration¶
As part of the individual assignment, I started exploring sensors and their logic.
The sensor I used is an infrared obstacle detection sensor, which detects the presence of an object in front of it.

Sensor and PCB Connection¶
The sensor was connected to my custom PCB using three pins:
- VCC → 3.3V
- GND → GND
- OUT → GPIO pin
This allowed the microcontroller to receive a digital signal from the sensor.

Code Implementation¶
Based on the sensor input, I wrote code to define a clear system behavior.
The system works in two main states:
- Normal state → green LED ON
- Detection state → yellow and red LEDs activate and blink

System Behavior¶
The logic of the code was built step by step:
- In normal conditions, the system stays in a safe state (green LED ON)
- When the sensor detects an object, the system changes state
- The green LED turns OFF
- Yellow and red LEDs turn ON
- Then they start blinking to indicate an alert
Video Demonstration¶
The following video shows how the system reacts in real time:
Conclusion¶
This experiment helped me understand how sensor input can be translated into system behavior.
It demonstrated a clear relationship between:
- input (sensor data)
- processing (code logic)
- output (LED behavior)
This approach is important for building interactive and intelligent systems.
Code¶
```cpp int value = analogRead(29); Serial.println(value);