Input Device
A. What are Input Devices?
Input Devices are those components which allow person to enter data, command, signals into a computer or microcontroller. This helps to interact with the outside world by receiving information from users, sensor, or other systems.
What are sensors?
A sensor is a type of input device, but it’s special because it can feel or sense something around it — like:
-
heat
-
light
-
sound
-
touch
-
motion
-
pressure
The sensor detects something in the environment and sends data to the machine.
Group Assignment
For this week's group assignment, we focused on probing the digital signals from an input device using the serial plotter in the Arduino IDE. We chose the HC-SR04 ultrasonic sensor and connected it to the RP2040 breakout board that we had designed earlier.
Working as a group helped us divide tasks—some handled the wiring and connections, while others worked on the code and monitored the serial output. Using the serial plotter, we could see the distance values change in real time as we moved objects in front of the sensor. This made it easy to observe how digital sensors communicate through precise timing and pulse width.
Through this activity, I understood how digital sensors don’t just give HIGH/LOW states—they can encode continuous values using time-based signals. It was also a great opportunity to test and reuse the custom board we had worked on earlier.
For more detail, please visit Group assignment page
Individual Assignment
B. Trying Flex Sensor
I finally got to try out a flex sensor for the first time!
The plan was simple—if the sensor bends past a certain point, an LED should blink.
Making sure all the connections were easy. The sensor was hooked up to an analog pin, a 10KΩ resistor to GND, and an LED to a digital pin.
Connection
Component | Pin on Component | Connects To RP2040 Pin | Notes |
---|---|---|---|
Flex Sensor | One leg | 3.3V | Power |
Flex Sensor | Other leg | GP26 (A0) | Analog input & resistor here |
10k Resistor | One leg | GP26 (A0) | Voltage divider setup |
10k Resistor | Other leg | GND | Ground |
LED (long leg) | Anode (+) | GP16 (D3) | Digital output |
LED (short) | Cathode (-) | GND | Via 220Ω resistor if needed |
But. this dd not work out. I tried changing codes thrice, but led wasn't blinking.
It was important to ensure that the processor which was in use, in arduiono IDE was installed in Library.
Since, code was not not working, planned to check indiviaually whether led, jumper connections, sensor were at right place. Went ahead by checking Serial Monitor.
Readings were between 2-3-4, but it should have been somewhere from 500-600. Here, error was found. Something was wrong with sensor connection input.
Then, figured out the working together which is documented on Sohan
C. Testing Button as Input
Since final project needs a button to trigger the camera, I wanted to test how a button works as an input on the RP2040 board. I connected a push button and an LED. When I press the button, the LED turns on — this acts like a test version of my camera trigger.
To make the connection safe and work properly, I added a 220Ω resistor with the LED. I also used INPUT_PULLUP in the code, which means I didn’t need an extra resistor for the button. This test helped me understand how digital inputs work and how to control output (like an LED) with a button press.
Connection
Component | RP2040 Pin | Notes |
---|---|---|
Button – leg 1 | D2 | Digital input pin with INPUT_PULLUP |
Button – leg 2 | GND | Connected to ground |
LED – anode | D3 | Connect with a 220Ω resistor |
LED – cathode | GND | Connected to ground |
D. Using a Potentiometer
In final project, the camera will include a zoom feature (either digital or mechanical). To control this smoothly and manually, I tested a potentiometer as a way to adjust the zoom level.
Turning the potentiometer changes the analog value (0 to 65535), which I can then map to control a zoom mechanism —like moving a lens forward and backward using a servo motor or stepper motor.
The potentiometer acts as a voltage divider. As you turn the knob, the middle pin outputs a voltage between 0V and 3.3V. The RP2040 reads this as an analog value from 0 to 65535 (16-bit resolution).
Connection
Component | Pin on Component | Connects To RP2040 Pin | Description |
---|---|---|---|
Potentiometer | Left (VCC) | 3.3V | Power supply |
Potentiometer | Right (GND) | GND | Ground |
Potentiometer | Middle (Signal) | GP26 (A0) | Analog input (reads values) |
E. Trying Out an LDR Sensor
The LDR is a simple sensor that changes resistance based on light intensity:
More light → less resistance
Less light → more resistance
Using this, can read light levels as analog values and use them to trigger different actions — like taking a photo when it gets dark, or adjusting brightness dynamically.
Connection
Component | Pin on Component | Connects To RP2040 Pin | Description |
---|---|---|---|
LDR | One leg | 3.3V | Power supply |
LDR | Other leg | GP26 (A0) | Analog input, shared with resistor |
10k Resistor | One leg | GP26 (A0) | Forms voltage divider with LDR |
10k Resistor | Other leg | GND | Connects to ground |
-
The values ranged depending on light intensity.
-
When I covered the LDR, the values dropped.
-
When exposed to bright light or flashlight, values increased.
This gives me a reliable input method to track light levels — which I can later use to:
-
Auto-capture a photo in low light
-
Warn if lighting is too bright or dark
-
Control screen/display brightness
F. DHT11 Temperature Sensor
For this setup, I used a DHT22 sensor to read both temperature and humidity using my ESP32-S3 board, and I wanted to keep things clean without using a breadboard.
I connected the sensor directly using female jumper wires
Connection Table
DHT Sensor Pin | ESP32-S3 Pin | Description |
---|---|---|
VCC | 3.3V | Power supply for the sensor |
DATA | GPIO14 (any GPIO) | Digital data pin for communication |
GND | GND | Ground connection |
(Optional) | 10kΩ Resistor | Between VCC and DATA as pull-up (if using raw sensor) |
I used GPIO4 for the data pin, but you can pick any other digital pin if needed.
Libraries Installed (Arduino IDE):
To make the sensor work, I installed two libraries:
-
DHT sensor library by Adafruit
-
Adafruit Unified Sensor library
You can get them from Tools → Manage Libraries in Arduino IDE. Just search “DHT” and install the one by Adafruit.
Have tried few more input devices in Output Device Week
Programming Process for Input Devices
When working with input devices like sensors on a microcontroller (such as ESP32 or Arduino), I followed a step-by-step programming process:
1.Importing Libraries
Some sensors need extra libraries to function properly. These libraries help the board understand how to communicate with the sensor.
2.Defining Pins
I assigned the correct pins on the microcontroller where the sensor or input device is connected. This helps the board know where to read the data from.
3.Setup Function
In the setup section, I prepared the board to start reading data. This includes starting the serial monitor (to see sensor readings) and setting up any necessary pin modes.
4.Loop Function
This part runs continuously. Here, I read the data from the input device or sensor again and again. Based on the values, I can decide what the system should do next—like turning on an LED, moving a motor, or printing the result.
Summary
The programming process included:
Adding libraries (only if needed)
Setting up pin connections
Initializing the system to start reading inputs
Continuously reading sensor data and responding
About the Code
The base code for the input device was generated using ChatGPT and served as a starting point. It was then modified to match the actual wiring and setup with the ESP32.
Key adjustments included:
Changing pin numbers according to the connections
Tuning delay values and thresholds for accurate sensor response
Removing unnecessary parts of the code
Adding simple logic to trigger outputs based on sensor input
The serial monitor was used to observe live readings and confirm the sensor's behavior. The final code was shaped through trial, error, and small tweaks to fit the project's specific needs