Week 10

Output Devices

Class with Neil

During Week 10 – Output Devices, the main objective was to design and integrate systems that allow the electronic board to interact with the external environment by generating outputs. This process focused on using components such as actuators, displays, and indicators that can respond to signals from the microcontroller.

The workflow included key stages such as output device selection, circuit design, PCB integration, programming, and functional testing. Through this process, I learned how to properly control output devices from a microcontroller, considering aspects such as voltage requirements, current consumption, and signal control.

This assignment allowed me to better understand how electronic systems can produce visible or physical responses, strengthening my skills in actuator control, programming, and embedded system design. ⚙️💡

Week 01 Image

Group Assignment:

°Measure the power consumption of an output device.

° Document your work on the group work page and reflect on your individual page what you learned.

Have you answered these questions?

  • I. Linked to the group assignment page.
  • II.Documented how you determined power consumption of an output device with your group.
  • III.Documented what you learned from interfacing output device(s) to microcontroller and controlling the device(s).
  • IV. Linked to the board you made in a previous assignment or documented your design and fabrication process if you made a new board.
  • V. Explained how your code works.
  • VI.Explained any problems you encountered and how you fixed them.
  • VII.Included original source code and any new design files.
  • VII.Included a ‘hero shot’ of your board.

Group Assignment Sumary

For the group assignment, we worked at the Universidad del Pacífico in Lima, where we tested and validated output devices using a PCB designed by Adrian Torres. In this case, we focused on programming and integrating a LCD I2C display and an SG90 servo motor, controlled by a XIAO RP2040.

As a team, we developed code to display information on the LCD while simultaneously controlling the servo motor’s movement. This allowed us to observe how the microcontroller sends output signals actuators and displays. ⚙️📟 to both visual and mechanical components, analyzing their behavior and response.

Through this collaborative experience, we gained a better understanding of how output devices operate in real applications, as well as how to properly control and synchronize multiple outputs within an embedded system. This was essential for strengthening our knowledge for our individual projects involving

GRUPL

Group Assignment Sumary

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.

Week 06 Image

1.Router Tools Used

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. ⚙️💡

🔩 0.5 mm 30° V-Bit (o V-Carving Bit)

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.

🔩 2 mm Carbide End Mill (Flat End Mill)

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. 🔩

🚪 Bakelite 1.6 mm PCB Material

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. ⚙️💡

Week 06 Image

🔍 Refletions Dsiplay I2C-Servo motor

During this group assignment, I gained practical experience working with output devices, specifically the LCD I2C display and the SG90 servo motor. By programming both components using the XIAO RP2040, I was able to understand how a microcontroller can control visual outputs and mechanical movements at the same time.

One of the most valuable aspects was observing how the LCD displayed real-time information while the servo responded to programmed instructions. This helped me better understand the relationship between code and physical output, as well as how to manage multiple devices within the same system.

Overall, this experience strengthened my understanding of output device integration, timing, and control, which will be essential for developing more interactive and functional systems in my future projects. ⚙️📟

Week 01 Image

individual Assignment:

° Add an output device to a microcontroller board you've designed and program it to do something.

1. Introduction

In this individual assignment, I focused on working with output devices by developing a system that integrates a servo motor and an OLED display using the XIAO ESP32 S3. The objective was to understand how a microcontroller can generate both visual and mechanical outputs in response to programmed instructions.

Through this process, I programmed the OLED display to show information while simultaneously controlling the movement of the servo motor. This allowed me to explore how different output devices can be synchronized and managed within the same system.

This assignment helped me strengthen my skills in embedded programming and output control, bringing me closer to developing interactive and functional systems for my final project. ⚙️📟

Week 01 Image

PCB Components List

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 ESP32-S3 1
2 Header 01x05 P2.54 mm Horizontal SMD 4
3 Resistor 1KΩ 1% 1206 3
4 OLED DISPLAY 1
5 SERVOMOTOR 1

📟PCB Components

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. ⚙️📡

Week 01 Image

📍 2. Ubication

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.

Week 01 Image

📈3. Simulation of the circuit:

Before implementing the physical setup, I simulated the circuit to validate the interaction between the XIAO ESP32 S3, the OLED display, and the servo motor. This allowed me to verify the logic of the program and ensure that both output devices responded correctly to the microcontroller.

During the simulation, I checked how the OLED displayed information and how the servo motor reacted to the programmed signals, confirming proper synchronization between visual and mechanical outputs. This step also helped me identify and correct potential errors in connections and code before moving to the real implementation.

Week 01 Image

⚙️4. Code visualization

In this stage, I analyzed the program used to control the OLED display and the servo motor with the XIAO ESP32 S3. By reviewing the code, I was able to understand how the display is initialized and updated, as well as how the servo receives control signals through PWM.

The code structure allowed me to clearly identify how both output devices are managed simultaneously, including the functions used to display information and control the servo’s position. This helped me verify pin configurations, timing, and the coordination between visual and mechanical outputs.

Week 01 Image

⚙️1. Programming Process-Smart Output System with OLED Display and Servo Control

Programming Process: Potentiometer Reading with Arduinio IDE

Once in the directory, I open the new script files marked in a green box, using the Rhinoceros program.

Week 01 Image

Code Writing in Arduino IDE


#include 
#include 
#include 
#include 

// OLED configuration
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

// Servo configuration
Servo myServo;
int servoPin = 5; // Cambia según tu conexión

void setup() {
  Serial.begin(115200);

  // Inicializar OLED
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("OLED not found");
    while(true);
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);

  // Inicializar Servo
  myServo.attach(servoPin);

  // Mensaje inicial
  display.setCursor(0,0);
  display.println("System Ready");
  display.display();
  delay(2000);
}

void loop() {

  // Posición 0°
  myServo.write(0);
  display.clearDisplay();
  display.setCursor(0,0);
  display.println("Servo Position:");
  display.println("0 degrees");
  display.display();
  delay(2000);

  // Posición 90°
  myServo.write(90);
  display.clearDisplay();
  display.setCursor(0,0);
  display.println("Servo Position:");
  display.println("90 degrees");
  display.display();
  delay(2000);

  // Posición 180°
  myServo.write(180);
  display.clearDisplay();
  display.setCursor(0,0);
  display.println("Servo Position:");
  display.println("180 degrees");
  display.display();
  delay(2000);
}

Programming Process: OLED Display + Servo SG90 (ESP32 S3)

1.1. Libraries and Objects

#include 
#include 
#include 
#include 

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Servo myServo;
int servoPin = 5;

- Wire: Enables I2C communication.
- Adafruit_SSD1306: Controls the OLED display.
- ESP32Servo: Controls the servo motor.
- servoPin: Defines the GPIO used for the servo.

1.2. Setup Configuration

void setup() {
  Serial.begin(115200);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("OLED not found");
    while(true);
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);

  myServo.attach(servoPin);

  display.setCursor(0,0);
  display.println("System Ready");
  display.display();
  delay(2000);
}

- Initializes serial communication.
- Verifies OLED connection (I2C address 0x3C).
- Configures display and attaches the servo.
- Shows initial system message.

1.3. Servo Movement (0°)

myServo.write(0);

- Moves the servo motor to 0 degrees.

1.4. Display Information on OLED

display.clearDisplay();
display.setCursor(0,0);
display.println("Servo Position:");
display.println("0 degrees");
display.display();

- Updates the OLED screen with the current servo position.

1.5. Servo Positions Loop

myServo.write(90);
delay(2000);

myServo.write(180);
delay(2000);

- Moves the servo to different angles (90° and 180°).
- Uses delays to allow smooth visualization and movement.

1.6. Loop Execution

delay(2000);

- Adds delay between movements for stability and readability.

✅1.7 Program Objective

Control a servo motor while displaying its position in real time on an OLED screen, demonstrating synchronization between mechanical and visual output devices.

⚙️1.8. OLED display (SSD1306)

The OLED display (SSD1306) is a compact output device that uses I2C communication (SDA and SCL), making it easy to integrate with the XIAO ESP32 S3. It offers low power consumption and high contrast since each pixel emits its own light. In my project, it serves as a user interface to display real-time information such as system status, servo position, or messages like “Ready” or “Dispensing,” improving interaction and making the system more intuitive and functional. 📟⚙️

Week 01 Image

⚙️1.9. SG90 servo motor

The SG90 servo motor is a compact actuator controlled by PWM signals, allowing precise movement between 0° and 180° using a microcontroller like the XIAO ESP32 S3. It requires simple connections (VCC, GND, and signal) and is ideal for prototyping. In my project, it is used as the main mechanism of the pill dispenser, controlling the release of doses by moving to specific angles, while working together with the OLED display to provide feedback and ensure accurate operation. ⚙️📟

Week 01 Image

⚙️1.9 I made a Simple Scetch

In this step, I created a simple sketch to represent the connection between the XIAO ESP32 S3 and the SG90 servo motor. Based on the diagram, I defined the main wiring by connecting VCC to 5V and GND to GND, ensuring proper power supply to the servo.

For signal control, I assigned the signal pin of the servo to a GPIO pin on the microcontroller, which allows sending PWM signals to control its position. In the sketch, these connections are represented as control lines, helping to clearly understand how the ESP32 S3 sends commands to move the servo to specific angles.

Week 01 Image

⚙️ I tested in PCB

In this stage, I tested the circuit directly on the fabricated PCB using the XIAO ESP32 S3 as the main microcontroller. After assembling the components, including the OLED display and the SG90 servo motor, I powered the board and uploaded the program.

I verified the correct operation of the output devices by observing the information displayed on the OLED and the movement of the servo motor. This allowed me to confirm that the connections, control signals, and overall system performance were working properly, ensuring proper synchronization between visual and mechanical outputs. ⚙️📟

📟Difficulties (Individual)

During this assignment, one of the main difficulties I faced was configuring the communication between the XIAO ESP32 S3 and the OLED display, as sometimes the screen did not respond correctly due to I2C address or wiring issues. Additionally, I had to ensure proper power supply for the SG90 servo motor, since unstable voltage could affect its performance.

Another challenge was synchronizing both output devices in the code, making sure that the servo movement and the OLED updates worked smoothly without conflicts or delays. However, through testing and adjustments, I was able to solve these issues and achieve a stable and functional system. ⚙️💻📟

📟Group Challenges

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. ⚙️🪵

📟7. What We Learned (Group)

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.

Week 01 Image

Files

Here are the project files available for download: