Week 9 — Input devices¶
Introduction¶
This week focused on understanding how devices communicate with each other and how data is transmitted between systems.
As a first step, I explored analog and digital signals, how input devices generate data, and how a microcontroller interprets that data.
Group Assignment — Input Devices¶
Overview¶
During the group assignment, we explored different input devices and analyzed how they generate electrical signals.
The goal was to understand how physical interaction is converted into measurable data.

Input Device — Potentiometer¶
We used a potentiometer as an analog input device.
The potentiometer works as a variable resistor and produces a continuous voltage depending on its position.

Signal Measurement Using Oscilloscope¶
To analyze the signal more deeply, we used an oscilloscope.
This allowed us to observe how the voltage changes in real time when the potentiometer is rotated.

Video¶
The following video shows the real-time signal behavior:
Observations¶
- The signal changes smoothly when rotating the potentiometer
- Voltage increases and decreases continuously
- Small fluctuations (noise) are present
- The signal is stable and predictable
Conclusion¶
This experiment helped us understand how input devices generate analog signals and how those signals can be measured using professional tools.
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);