During Week 09 – Input Devices, the main objective was to design and integrate input systems that allow the electronic board to receive data from the external environment. This process focused on incorporating sensors and components capable of detecting physical changes such as light, motion, or touch, and converting them into readable electronic signals.
The workflow included key stages such as sensor selection, circuit design, PCB integration, programming, and signal testing. Through this process, I learned how to properly interface input devices with a microcontroller, considering aspects such as signal conditioning, voltage levels, and data acquisition.
This assignment allowed me to better understand how electronic systems interact with real-world inputs, strengthening my skills in sensor integration, programming, and embedded system design.
Group Assignment:
°Probe an input device(s)'s analog levels and digital signals (As a minimum, you should demonstrate the use of a multimeter and an oscilloscope.)
° Document your work on the group work page and reflect on your individual page what you learned
For the group assignment, we met at the FABLAB UNI, where we had the opportunity to test and validate input devices using a PCB designed by Adrian Torres. This board allowed us to experiment with different sensors, specifically an ultrasonic sensor and an LDR sensor, enabling us to analyze how input signals are captured and processed.
As a team, we focused on understanding how these sensors interact with the microcontroller, exploring their behavior and response under different conditions. We tested how the ultrasonic sensor measures distance and how the LDR detects variations in light intensity, observing the changes in output signals.
Through this collaborative experience, we gained a better understanding of how input devices work in real applications, as well as how to properly integrate and test them within an electronic system. This was key to strengthening our knowledge for developing our individual projects involving sensor-based inputs. ⚙️💡
Later, we met in person at the FabLab UNI to carry out the group assignment. At the beginning of the session, we received an additional safety briefing before operating the Roland SMR20 CNC router, where we reviewed the proper procedures and precautions needed to safely work with large computer-controlled machines in the lab.
For the PCB fabrication process, we used a Roland SRM-20 CNC milling machine, which provides high precision for electronic production in Fab Labs. During the machining process, different milling bits were selected depending on the task: 0.1 mm and 0.5 mm bits were used for fine traces to achieve detailed and accurate circuit paths, while a 2 mm bit was used for cutting and defining the board outline. The correct selection of these tools was essential to ensure clean results, avoid errors in the traces, and obtain a well-fabricated PCB. ⚙️💡
This milling tool is primarily used for CNC machines and is made of tungsten steel, which provides high durability and precision during machining. It features a 3.175 mm shank, a 0.5 mm cutter tip, and a 30° tip angle, making it suitable for detailed and fine cutting operations. This type of tool is commonly used for processing materials such as bakelite, acrylic, PVC, wood, MDF, and similar derivatives, allowing clean and accurate results in PCB and general fabrication tasks.
The 2 mm Carbide End Mill is a flat-end cutting tool widely used in CNC machining for precise cutting and material removal. It is made of tungsten carbide, which provides high hardness, durability, and resistance to wear, while the titanium coating helps reduce friction and improves tool lifespan.
This tool features a 3.175 mm shank diameter, a 2 mm cutting diameter, and a 12 mm cutting length, making it suitable for detailed cutting tasks. It is commonly used for PCB cutting, MDF, and plywood, especially for contouring and profiling operations. Due to its flat tip, it allows clean edges and accurate cuts, making it ideal for defining the final shape of machined parts. 🔩
The 1.6 mm Bakelite board is a commonly used substrate for PCB fabrication, especially in CNC milling processes. It is made from phenolic resin and paper layers, providing a rigid and stable structure suitable for electronic circuits. This material is widely used due to its good electrical insulation properties, low cost, and ease of machining.
With a thickness of 1.6 mm, it offers an ideal balance between mechanical strength and workability, making it suitable for both traces milling and board cutting. Bakelite is compatible with CNC tools such as V-bits and end mills, allowing precise fabrication of circuit paths and clean board outlines. Additionally, it is a reliable option for prototyping electronic boards in Fab Lab environments. ⚙️💡
During this assignment, I gained practical experience working with input devices, specifically the ultrasonic sensor and the LDR sensor. We started by programming the ultrasonic sensor and used the Serial Monitor in the Arduino IDE to observe the distance data in real time. This allowed me to clearly understand how the sensor captures and transmits information.
Additionally, we used the Serial Plotter, which provided a graphical representation of the data. This visualization made it easier to analyze how the values changed over time and helped me better interpret the sensor behavior.
Overall, this experience helped me understand how to read, analyze, and visualize input data from sensors, reinforcing my knowledge in embedded programming and real-world interaction with electronic systems. ⚙️📊
During this assignment, I gained practical experience working with input devices, specifically the ultrasonic sensor and the LDR sensor. We started by programming the ultrasonic sensor and used the Serial Monitor in the Arduino IDE to observe the distance data in real time. This allowed me to clearly understand how the sensor captures and transmits information.
Additionally, we used the Serial Plotter, which provided a graphical representation of the data. This visualization made it easier to analyze how the values changed over time and helped me better interpret the sensor behavior.
Overall, this experience helped me understand how to read, analyze, and visualize input data from sensors, reinforcing my knowledge in embedded programming and real-world interaction with electronic systems. ⚙️📊
individual Assignment:
° Measure something: add a sensor to a microcontroller board that you have designed and read it.
In this individual assignment, I focused on working with different input devices to understand how electronic systems can interact with the real world. For this purpose, I used three sensors: the HC-SR04 Ultrasonic Sensor, the TCRT5000 (3-pin module), and the TTP223 Capacitive Touch Sensor.
Each of these sensors allowed me to explore different types of input signals. The ultrasonic sensor was used to measure distance, the TCRT5000 helped detect proximity or line tracking based on infrared reflection, and the touch sensor enabled interaction through physical contact. Notably, the TCRT5000 will be especially important for my final project, as it will be used as part of the detection system.
Through this process, I was able to understand how to read and interpret data from multiple sensors, integrate them with a microcontroller, and apply them to real-world applications, bringing me closer to the development of my final project. ⚙️📡
For this assignment, I used the SEEED STUDIO XIAO RP2040 as the main controller, along with a 1KΩ resistor and a Header 01x05 for connections. I also integrated three sensors: the TTP223 touch sensor, the HC-SR04 ultrasonic sensor, and the TCRT5000 module, allowing me to capture and process different types of input signals. ⚙️📡
| Item | Component | Amount |
|---|---|---|
| 1 | SEEED STUDIO XIAO RP2040 | 1 |
| 2 | Header 01x05 P2.54 mm Horizontal SMD | 4 |
| 3 | Resistor 1KΩ 1% 1206 | 3 |
| 4 | TTP223 Capacitive Touch Sensor | 1 |
| 5 | HC-SR04 Ultrasonic Sensor | 1 |
| 6 | TCRT5000 (3-pin module) | 1 |
The PCB integrates the SEEED STUDIO XIAO RP2040 as the central microcontroller, connected to essential supporting components such as a 1KΩ resistor and a Header 01x05 for external interfacing. Additionally, it includes input devices like the TTP223 capacitive touch sensor, the HC-SR04 ultrasonic sensor, and the TCRT5000 module, enabling the system to detect touch, measure distance, and sense proximity or line tracking signals. These components work together to create a functional input-based electronic system. ⚙️📡
The electronic components used in this project were sourced from Saisac Mecatrónica, a specialized electronics supplier located in the city of Lima. This store offers a wide range of components suitable for PCB design and prototyping. For reference, the exact location of the store can be accessed through Google Maps at: Jr. Paruro 1349, Lima 15003.
After completing the PCB design in KiCad, I exported the board layout in a compatible format (such as SVG or DXF) to be used in Rhinoceros. This step allowed me to work with the PCB geometry in a more flexible environment for visualization and additional adjustments.
Once imported into Rhinoceros, I verified the scale, alignment, and dimensions of the traces and board outline to ensure accuracy. This process helped me prepare the design for further processing, such as organizing layers, refining details, or generating toolpaths for CNC machining.
Using Rhinoceros as an intermediate tool allowed me to have better control over the geometry and ensured that the final design was clean and ready for fabrication. 📐⚙️
For this stage, I focused on visualizing and analyzing the program used to control the input devices. By reviewing the code structure, I was able to clearly identify how each sensor—such as the ultrasonic sensor, touch sensor, and TCRT5000—was initialized, read, and processed by the microcontroller.
The code visualization helped me understand the logic flow, including how input signals are captured, interpreted, and displayed through serial communication. It also allowed me to verify pin configurations, timing functions, and conditional statements used to control the system behavior.⚙️💻
Once in the directory, I open the new script files marked in a green box, using the Rhinoceros program.
HC-SR04 Ultrasonic Sensor Code
#define TRIG_PIN D1
#define ECHO_PIN D0
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
}
void loop() {
long duration;
float distance;
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(5);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration = pulseIn(ECHO_PIN, HIGH, 30000);
if (duration == 0) {
Serial.println(0); //
} else {
distance = (duration * 0.0343) / 2;
Serial.println(distance); //
}
delay(100);
}
#define TRIG_PIN D1
#define ECHO_PIN D0
- TRIG_PIN: Used to send the ultrasonic pulse signal.
- ECHO_PIN: Used to receive the reflected signal from the object.
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
}
- Serial.begin(115200): Initializes serial communication.
- pinMode: Configures TRIG as output and ECHO as input.
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(5);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
- Sends a short pulse (10 microseconds) to trigger the ultrasonic sensor.
duration = pulseIn(ECHO_PIN, HIGH, 30000);
- pulseIn(): Measures the time the signal stays HIGH.
- Timeout is set to avoid blocking if no signal is received.
if (duration == 0) {
Serial.println(0);
} else {
distance = (duration * 0.0343) / 2;
Serial.println(distance);
}
- Converts time into distance using the speed of sound.
- Divided by 2 because the signal travels to the object and back.
delay(100);
- Adds a small delay between measurements for stability.
Measure the distance between the sensor and an object using ultrasonic waves, and display the result in real time through the Serial Monitor.
The HC-SR04 Ultrasonic Sensor is a sensor used to measure distance without contact using ultrasonic waves. It sends a sound wave and calculates the distance based on the time it takes to bounce back from an object. Key specifications: operates at 5V, measures from 2 cm to 4 m, has an accuracy of ±3 mm, and uses a 40 kHz frequency. It has 4 pins: VCC, GND, TRIG (signal output), and ECHO (signal input).
In this step, I created a simple sketch to represent the connection between the XIAO RP2040 and the HC-SR04 ultrasonic sensor. Based on the diagram, I defined the main wiring by connecting VCC to 5V and GND to GND, ensuring proper power supply to the sensor.
For signal communication, I assigned the TRIG and ECHO pins of the sensor to available GPIO pins on the microcontroller. In the sketch, these connections are visualized similarly to communication lines, helping to clearly identify how the sensor sends and receives signals.
In this stage, I tested the circuit directly on the fabricated PCB using the XIAO ESP32 S3 as the main microcontroller. After assembling all components and connecting the sensors, I powered the board and uploaded the program.
I verified the correct operation of each input device—including the ultrasonic sensor, touch sensor, and TCRT5000—by monitoring the data through the Serial Monitor. This allowed me to confirm that the connections, signal readings, and overall system performance were working properly.
Once in the directory, I open the new script files marked in a green box, using the Rhinoceros program.
#define TRIG_PIN 9
#define ECHO_PIN 10
long duration;
float distance;
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
}
void loop() {
// Ensure clean pulse
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
// Send 10 µs pulse
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Read echo time
duration = pulseIn(ECHO_PIN, HIGH);
// Calculate distance in cm
distance = duration * 0.0343 / 2;
// ---- Serial Monitor ----
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// ---- Serial Plotter ----
// Only numeric values for plotting
Serial.println(distance);
delay(100);
}
#include "DHT.h"
- DHT library: Used to interface with the DHT11 sensor and read temperature and humidity values.
#define DHTPIN D2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
- DHTPIN: Digital pin where the sensor is connected.
- DHTTYPE: Specifies the sensor model (DHT11).
- DHT object: Initializes the sensor.
void setup() {
Serial.begin(115200);
dht.begin();
}
- Serial.begin(115200): Starts serial communication.
- dht.begin(): Initializes the sensor.
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
- Reads temperature in Celsius and humidity percentage from the sensor.
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Error reading from DHT11");
} else {
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}
- isnan(): Checks if the reading failed.
- If valid, the data is printed to the Serial Monitor.
delay(2000);
- The DHT11 sensor requires a delay between readings (minimum 1–2 seconds).
Measure environmental temperature and humidity using the DHT11 sensor and display the values in real time through the Serial Monitor. This allows monitoring environmental conditions for further analysis.
In this step, I created a simple sketch to represent the connection between the XIAO ESP32 S3 and the DHT11 temperature and humidity sensor. The diagram defines the basic wiring, connecting VCC to 3.3V, GND to GND, and the DATA pin to a digital GPIO of the microcontroller.
This sketch helped me clearly understand how the sensor communicates with the ESP32 S3 using a single data line, where both temperature and humidity values are transmitted. It also allowed me to verify the correct pin configuration before implementing the physical circuit.🌡️💧⚙️
In this stage, I tested the DHT11 temperature and humidity sensor directly on the fabricated PCB using the XIAO ESP32 S3 as the main microcontroller. After connecting the sensor to the corresponding power, ground, and data pin, I uploaded the program to read temperature and humidity values.
I monitored the output through the Serial Monitor, where I was able to observe real-time environmental data. This allowed me to verify that the sensor was correctly connected and communicating properly with the microcontroller.
After generating the toolpaths, I saved the G-code file and transferred it to the CNC machine. The file was then loaded into the ShopBot3 Router control software, which is used to operate the CNC router.
Through this program, I prepared the machine to start the fabrication process. Once the file was loaded, the CNC machine followed the programmed toolpaths to cut the parts from the bakelite accurately, allowing the components of the shelf to be produced for the assembly stage. ⚙️🪵
During the fabrication process, I encountered an issue when trying to send the cutting job to the Roland CNC Router. There was a misconfiguration in the machine drivers, which prevented proper communication between the computer and the CNC..
This problem delayed the start of the milling process, as I had to review and correct the driver settings to ensure the machine was correctly recognized and could receive the G-code files. After troubleshooting and reconfiguring the drivers, I was able to restore the connection and continue with the fabrication process normally..
During the group work, one of the main challenges was coordinating the use of the CNC machine and organizing the workflow among team members. Since several people needed to use the equipment, we had to carefully plan the machining times and preparation steps to avoid delays.
Another challenge was ensuring that everyone correctly understood the CNC preparation process, including setting the X, Y, and Z axes, fixing the material properly on the machine bed, and verifying the toolpaths before starting the cutting process. Small mistakes in these steps could affect the machining results.
Through collaboration and discussion, we were able to solve these issues by helping each other review the machine setup, checking the files before cutting, and sharing our observations during the fabrication process. This teamwork helped us achieve more accurate and safer results when using the CNC router. ⚙️🪵
As a team, we learned how to safely test an electronic board before measuring signals by first checking the power connections and possible short circuits using a multimeter. After confirming that the board was working correctly, we used the oscilloscope to analyze the signal generated by the Raspberry Pi Pico, connecting the probe ground to GND and the tip to the corresponding GPIO pin.
We also learned how oscilloscope settings such as VOLTS/DIV, TIME/DIV, and the trigger configuration affect signal visualization. Through troubleshooting issues like incorrect pin selection or unstable trigger settings, we were able to obtain a clear and stable signal and understand the difference between a multimeter reading and an oscilloscope waveform.
Here are the project files available for download: