Week 10: Output Devices
This week, I focused on integrating and programming an output device using the custom copper PCB I designed during Week 06 and fabricated during Week 08. I selected a 2.8-inch ILI9341 TFT display because it directly supports the handheld console portion of my final project, MARGIN.
Rather than developing an isolated display demonstration, I wanted to build upon my previous assignments by integrating the display with my existing textile pressure sensor, UV sensor, and vibration motor. This allowed me to explore how multiple input and output devices can operate together using a single microcontroller.
Connection to My Final Project
MARGIN is a two-part reflective journaling companion consisting of a handheld console and a wearable device. This week's assignment allowed me to prototype the core interaction between the two systems on a single PCB.
The display presents a journaling prompt, the textile button advances the prompt, the UV sensor provides an estimated UV index, and the vibration motor delivers a reminder when the designated response window expires.
Successfully integrating these components demonstrated the feasibility of my final project's core interaction loop. Although the display module also supports touchscreen functionality, this week's assignment focuses specifically on its visual output capabilities.
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.
As a remote student at the UNC Charlotte Fab Academy node, I am coordinating with my instructor regarding the group measurement activity and documentation requirements.
The objective of this assignment is to understand the electrical power consumption of an output device and how its operating conditions influence the overall power requirements of an embedded system.
Group Assignment: UNC Charlotte Fab Academy Node
Output Device Power Consumption
Understanding power consumption is particularly important for my final project because the handheld console is intended to operate using a rechargeable battery. The TFT display, its backlight, and the vibration motor all contribute to the system's total power requirements.
I expect the display backlight to contribute significantly to the system's power consumption. Comparing the current draw under different operating conditions will allow me to evaluate this assumption and make more informed decisions about battery selection.
Measurement Procedure
- Disconnect power from the circuit before configuring the multimeter.
- Configure the multimeter for DC current measurement using the appropriate input terminal and measurement range.
- Connect the multimeter in series with the circuit's power supply.
- Power the circuit and record the current under each operating condition.
- Measure the supply voltage using the multimeter in voltage mode, connected in parallel with the supply.
- Calculate the electrical power consumed under each operating condition.
Power Calculation
Electrical power is calculated using the following equation:
P = V × I
- P = Electrical power in watts (W)
- V = Supply voltage in volts (V)
- I = Current in amperes (A)
When current is measured in milliamperes, multiplying voltage by current produces power in milliwatts (mW).
Power Consumption Measurements
| Operating Condition | Voltage (V) | Current (mA) | Power (mW) |
|---|---|---|---|
| System operating with backlight off | Pending | Pending | Pending |
| Backlight on with static prompt | Pending | Pending | Pending |
| Backlight on with active screen updates | Pending | Pending | Pending |
| System during motor activation | Pending | Pending | Pending |
Comparing the baseline measurement with the backlight-enabled measurement will help determine the additional power consumed by the display backlight.
Group Assignment Reflection
This assignment highlighted the importance of considering power consumption when selecting and integrating output devices. A component's functionality is only one part of determining whether it is appropriate for a portable embedded system.
I learned that current consumption can vary depending on the operating state of a device. For a TFT display, the backlight and display activity are factors that should be considered when evaluating overall power requirements.
For MARGIN, these measurements will inform future decisions regarding battery capacity, display brightness, screen timeout settings, and power management strategies.
Completing the physical measurements will allow me to compare my initial expectations with the actual electrical behavior of the system.
Individual Assignment
- Add an output device to a microcontroller board you've designed and program it to do something.
Individual Assignment: ILI9341 TFT Display
For my individual assignment, I selected a 2.8-inch TFT display with an ILI9341 controller and a resolution of 240 by 320 pixels. I connected this display to my previously designed and fabricated PCB and programmed it to function alongside the input and output devices I implemented in earlier assignments.
Why I Chose an LCD
My final project, MARGIN, is a reflective journaling companion consisting of two devices:
- Handheld Console: Presents journaling prompts, collects user responses, and provides information about environmental conditions. The final design is intended to store journal entries locally on an SD card without requiring cloud connectivity or a user account.
- Wearable Wristband: Incorporates electronic components into a sustainable textile to provide haptic reminders and receive acknowledgment through a textile pressure sensor.
During Week 09, I gave my device the ability to sense its environment and receive user input. This week, I gave my device a way to communicate visually. The display is essential to the intended journaling experience because it provides the interface through which users receive prompts and feedback.
Why the Display Instead of the Keyboard?
Both a keyboard and a display are planned components of my handheld console. However, the keyboard primarily functions as an input device by sending keystrokes to the microcontroller, while the LCD functions as an output device by presenting information to the user.
Although my selected display module also includes touchscreen capabilities, the touchscreen is a separate input interface. For this assignment, I focused on programming the LCD's visual output rather than implementing touch functionality.
Programmed Output Functionality
Rather than simply displaying a static image or text, I programmed the display to perform several functions directly related to my final project:
- Present a journaling prompt upon startup.
- Advance to the next prompt when the textile button is pressed.
- Display an estimated UV index using readings from the UV sensor.
- Present a visual reminder when the 20-second response window expires.
- Operate alongside the vibration motor to provide both visual and haptic feedback.
This integrated demonstration allowed me to test the core interaction of my final project before developing its final hardware and enclosure.
How the Display Works
The display is a 2.8-inch TFT LCD controlled by an ILI9341 display controller. Communication between the display controller and my Seeed Studio XIAO RP2040 takes place using the Serial Peripheral Interface (SPI) protocol.
SPI is a synchronous serial communication protocol that allows a microcontroller to communicate with peripheral devices using a shared clock signal. The microcontroller sends commands and pixel data to the ILI9341 controller, which stores the image data in its internal display memory and refreshes the LCD panel.
SPI and Display Control Signals
- SCK (Serial Clock): Synchronizes data transmission between the microcontroller and display controller.
- MOSI / SDI: Carries commands and pixel data from the microcontroller to the display controller.
- MISO / SDO: Allows the peripheral to return data to the microcontroller when read operations are required.
- CS (Chip Select): Selects the display controller for communication.
- DC (Data/Command): Identifies whether transmitted information represents a command or display data.
- RST (Reset): Allows the microcontroller to reset the display controller during initialization.
- LED: Provides power to the display backlight independently of the display communication signals.
Future Peripheral Integration
While inspecting the back of the display module, I identified a separate header associated with the onboard microSD card slot. This is particularly useful for my final project because I intend to implement local storage for journal entries.
The display controller, microSD card, and compatible SPI touchscreen controller can potentially share the SPI bus, provided each peripheral has an independently controlled chip-select signal and compatible electrical connections.
For this week's assignment, I focused exclusively on communicating with the LCD controller. The touchscreen and microSD card functionality remain available for future development.
Building Upon My Previously Fabricated PCB
To satisfy the individual assignment requirement, I integrated the display into the custom PCB that I designed and fabricated during previous Fab Academy assignments rather than using a separate breadboard-based circuit.
The original PCB was designed with the wearable portion of my final project in mind. As my project developed, I expanded its functionality to accommodate additional input and output devices. The limited space between existing solder pads made this integration particularly challenging.
My previous assignments document the development of this system:
- Week 06: Electronics Design - Original circuit design, schematic development, and PCB layout.
- Week 08: Electronics Production - PCB fabrication, soldering, and initial board testing.
- Week 09: Input Devices - Integration of the textile pressure sensor and UV sensor.
For Week 10, I expanded the functionality of this existing board by connecting and programming the TFT display. This required careful pin allocation, direct soldering, and verification of electrical connections to preserve the functionality of previously installed components.
Circuitry and Wiring
BOM
| Component | Part / Description | Interface | Purpose |
|---|---|---|---|
| Microcontroller | Seeed Studio XIAO RP2040 | GPIO, SPI, ADC | System control |
| Custom PCB | Milled copper PCB | Direct soldered connections | Component integration |
| Display | 2.8-inch ILI9341 TFT LCD | SPI | Visual output |
| Textile Button | Velostat pressure sensor | Analog | Prompt advancement |
| UV Sensor | GUVA-S12SD module | Analog | Estimated UV index |
| Vibration Motor | DC motor with MOSFET driver | Digital output | Haptic reminder |
| Connection Materials | Hookup wire and solder | Direct connections | Electrical integration |
The TFT display is the primary new component introduced during Week 10. The remaining electronic components were carried forward from previous assignments to demonstrate an integrated system.
Connections
| Display Pin | XIAO Pin | RP2040 GPIO | Function |
|---|---|---|---|
| VCC | 3V3 | Power | 3.3V supply |
| GND | GND | Ground | Common ground |
| SCK | D8 | GPIO2 | SPI clock |
| SDI / MOSI | D10 | GPIO3 | Data sent to the display |
| CS | D1 | GPIO27 | Display chip select |
| DC / RS | D6 | GPIO0 | Data or command selection |
| RESET | D7 | GPIO1 | Display controller reset |
| LED | 3V3 | Power | Display backlight supply |
| SDO / MISO | D9 | GPIO4 | SPI readback; not used by the current sketch |
The GPIO assignments were referenced from the Seeed Studio XIAO RP2040 documentation.
Power Supply and Backlight
The prototype receives power through the XIAO's USB-C connection. The display is connected to the board's regulated 3.3V supply, and all components share a common ground.
The display module's backlight is connected separately to the 3.3V supply, allowing it to illuminate independently of SPI communication with the display controller.
Because the backlight is connected directly to the power supply rather than a programmable GPIO, it remains illuminated while the system is powered. Future iterations may incorporate controllable backlight brightness to improve battery efficiency.
Before applying power, I checked the connections for accidental shorts and verified that the display's power and ground wires were connected correctly.
Getting these pins connected was the most time consuming and stressful part of this week!!!!!!
It took me over 5 hours to get these pins connected without frying the board or distroying the touchscreen's components. I did a lot of work to ensure that the actual touchscreen remained "brand new".
Because I intended to reuse the display in my final console, I wanted to minimize damage to its original header pins and preserve its functionality throughout the prototyping process.
I prepared each connection by stripping the wire, attaching it to the appropriate display pin, and temporarily insulating the exposed connection. I used both color coding and individual labels to identify the wires before connecting them to the PCB.
This organization was particularly important because the display required several adjacent connections, and an incorrectly placed wire could create a short circuit or damage a component.
Although this method was useful for temporary prototyping, a future iteration will use more reliable connectors, appropriate electrical insulation, and dedicated strain relief.
I took the time to secure wires to the touchscreen's pins using a stripping and taping method that required extreme patience and labeling. I made sure to both color code each connection and label each wire to ensure that I did not accidently solder anything incorrectly. I also took the time to ensure that before I soldered anything, I did not have any wires or pins touching eachother.
Pin conflict notes
One of the primary challenges of integrating the display was assigning its control signals without interfering with the components I had previously connected or the interfaces I intended to use in my final project.
The hardware SPI pins were available for the display, but I needed to identify additional GPIO pins for chip select, data/command selection, and reset.
| XIAO Pin | RP2040 GPIO | Assigned Function | Status |
|---|---|---|---|
| D0 / A0 | GPIO26 | Velostat pressure sensor | In use |
| D1 | GPIO27 | TFT chip select | In use |
| D2 | GPIO28 | Motor control | In use |
| D3 / A3 | GPIO29 | UV sensor | In use |
| D4 | GPIO6 | I2C SDA - keyboard | Reserved |
| D5 | GPIO7 | I2C SCL - keyboard | Reserved |
| D6 | GPIO0 | TFT data/command | In use |
| D7 | GPIO1 | TFT reset | In use |
| D8 | GPIO2 | SPI clock | In use |
| D9 | GPIO4 | SPI MISO | Available for readback |
| D10 | GPIO3 | SPI MOSI | In use |
I selected D1, D6, and D7 for the display's control signals because they did not conflict with my existing components or the I2C interface reserved for future keyboard integration.
I also needed to distinguish between the display module's RESET connection and the microcontroller's own reset button. The display reset signal is controlled through D7, which is identified as TFT_RST in my Arduino sketch.
This pin allocation exercise demonstrated how quickly available GPIO resources can become limited when integrating multiple peripherals into a compact embedded system.
Direct PCB Integration
Through the pain and many many many desolders I got everything connected without the use of a breadboard and ensured that the display is soldered directly to the board.
After preparing and identifying the individual wires, I soldered the display connections directly to my previously fabricated PCB and the appropriate microcontroller connections without using a breadboard.
The original PCB was designed for a compact wearable application and did not include dedicated connectors for the display. Consequently, I needed to work within the limited spacing of the existing copper pads and microcontroller connections.
Several connections required rework and desoldering before I achieved a functional arrangement. Throughout this process, I used a multimeter to check continuity and identify unintended electrical connections before applying power.
This experience highlighted the importance of designing accessible connection points, allowing adequate soldering clearance, and considering future peripheral expansion during the initial PCB design process.
Setting up the IDE
Honestly, I didn't need to make many adjustments here since my RP2040 was already installed from weeks 8 and 9. In the Library Manager I added the Adafruit ILI9341 and GFX Library. When I did this it also added the Adafruit BusIO. Everything else is already in the core and the board remained the same on COM6, serial at 115200.
I continued using the Arduino IDE and the RP2040 board package configured during my previous assignments. Since the microcontroller and programming environment remained unchanged, I only needed to install the additional libraries required to communicate with the TFT display.
Development Environment
| Setting | Configuration |
|---|---|
| Programming Environment | Arduino IDE |
| Selected Board | Seeed Studio XIAO RP2040 |
| Serial Port | COM6 |
| Baud Rate | 115200 |
| ADC Resolution | 12-bit |
| Display Communication | Hardware SPI |
Required Libraries
Using the Arduino IDE Library Manager, I installed the libraries needed to communicate with and render graphics on the ILI9341 display.
- Adafruit ILI9341: Provides communication and control functions for the display controller.
- Adafruit GFX: Provides functions for rendering text, lines, shapes, and graphics.
- Adafruit BusIO: Provides communication support required by the Adafruit libraries.
- SPI: Provides hardware SPI communication and is included with the Arduino board package.
After installing the required libraries, I retained my existing board and serial port configuration and continued developing the integrated program.
Coding
Programming the Integrated System
Rather than developing a standalone display demonstration, I expanded my previous Arduino program to integrate the TFT display with the textile pressure sensor, UV sensor, and vibration motor. This allowed me to test the intended interaction between the input and output devices of my final project.
Program Structure
| Function | Purpose |
|---|---|
| setup() | Initializes communication, calibrates the pressure sensor, configures the motor, and initializes the display. |
| loop() | Reads the sensors, detects button presses, checks elapsed time, and updates the display. |
| showPrompt() | Renders the current journaling prompt and resets the response timer. |
| drawStatus() | Updates the estimated UV index displayed in the footer. |
| drawReminder() | Displays a visual reminder when the response window expires. |
| pulseMotor() | Activates the vibration motor for 500 milliseconds. |
System Initialization
During setup(), the program initializes serial communication at 115200 baud, configures the analog inputs for 12-bit readings, and initializes the motor output in its inactive state.
The program then establishes the resting baseline of the textile pressure sensor before initializing the TFT display in portrait orientation and rendering the first journaling prompt.
Source Code
// ─────────────────────────────────────────────────────────────
// Fab Academy Week 10 — Output Devices
// Heaven Whitby — handheld journaling console (test bench)
// Board: Seeed Studio XIAO RP2040 (custom milled PCB, Week 8)
//
// OUTPUT device under test:
// - 2.8" ILI9341 SPI TFT (240x320) — displays the journaling prompt
// Also driven (preserved): DC vibration motor via MOSFET on D2
// Inputs preserved from Week 9:
// - Velostat fabric button on A0/D0 (press = advance prompt)
// - GUVA-S12SD analog UV sensor on A3 (shown on screen)
// ─────────────────────────────────────────────────────────────
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS D1 // GP27
#define TFT_DC D6 // GP0
#define TFT_RST D7 // GP1
// SCK -> D8, MOSI -> D10, MISO -> D9 (default SPI); LED -> 3V3
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
const int velostatPin = A0;
const int uvPin = A3;
const int motorPin = D2;
// Velostat press = reading drops LOW. Auto-baselined at startup so the
// threshold adapts to the ADC scale (fixed Week 9's 10-bit -> 12-bit bug).
int velostatBaseline = 0; // measured at power-on (untouched)
const float PRESS_FRACTION = 0.5; // press = below 50% of resting baseline
int pressThreshold = 200; // computed in setup() from the baseline
const char* prompts[] = {
"What pulled your attention today?",
"Where did you feel most like yourself?",
"Name one thing you're carrying that isn't yours.",
"What would this morning's you want to hear right now?"
};
const int promptCount = sizeof(prompts) / sizeof(prompts[0]);
int currentPrompt = 0;
const unsigned long PROMPT_WINDOW_MS = 20000;
unsigned long promptStart = 0;
bool reminded = false;
bool wasPressed = false;
void setup() {
Serial.begin(115200);
analogReadResolution(12);
pinMode(motorPin, OUTPUT);
digitalWrite(motorPin, LOW);
// Auto-baseline the velostat — DO NOT press it at power-on.
long sum = 0;
for (int i = 0; i < 32; i++) { sum += analogRead(velostatPin); delay(5); }
velostatBaseline = sum / 32;
pressThreshold = (int)(velostatBaseline * PRESS_FRACTION);
Serial.print("Velostat baseline="); Serial.print(velostatBaseline);
Serial.print(" press threshold="); Serial.println(pressThreshold);
tft.begin();
tft.setRotation(0);
showPrompt();
Serial.println("Week 10 ready — LCD + velostat + UV + motor");
}
void loop() {
int pressure = analogRead(velostatPin);
int uvRaw = analogRead(uvPin);
float uvIndex = (uvRaw * (3.3 / 4095.0)) / 0.1;
Serial.print("pressure="); Serial.print(pressure);
Serial.print(" uvIndex="); Serial.println(uvIndex, 1);
bool pressed = (pressure < pressThreshold);
if (pressed && !wasPressed) {
currentPrompt = (currentPrompt + 1) % promptCount;
showPrompt();
}
wasPressed = pressed;
if (!reminded && (millis() - promptStart > PROMPT_WINDOW_MS)) {
pulseMotor();
drawReminder();
reminded = true;
}
drawStatus(uvIndex);
delay(200);
}
void showPrompt() {
promptStart = millis();
reminded = false;
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_CYAN); tft.setTextSize(2);
tft.setCursor(10, 12); tft.println("MARGIN");
tft.drawFastHLine(10, 38, 220, ILI9341_DARKGREY);
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(2);
tft.setTextWrap(true);
tft.setCursor(10, 60); tft.println(prompts[currentPrompt]);
}
void drawReminder() {
tft.setTextColor(ILI9341_ORANGE); tft.setTextSize(2);
tft.setCursor(10, 268); tft.println("take a moment...");
}
void drawStatus(float uvIndex) {
tft.fillRect(0, 300, 240, 20, ILI9341_BLACK);
tft.setTextColor(ILI9341_DARKGREY); tft.setTextSize(1);
tft.setCursor(10, 305);
tft.print("UV index: "); tft.print(uvIndex, 1);
}
void pulseMotor() {
digitalWrite(motorPin, HIGH);
delay(500);
digitalWrite(motorPin, LOW);
}
Understanding My Source Code
Display Rendering and Prompt Advancement
I stored four journaling prompts in a string array. The currentPrompt variable identifies which prompt is currently displayed.
The showPrompt() function clears the previous screen, renders the MARGIN heading, draws a horizontal separator, and displays the selected journaling prompt using the Adafruit graphics library.
When the textile sensor reading falls below the calibrated pressure threshold, the program identifies a button press. The wasPressed variable allows the program to detect a new press rather than repeatedly advancing prompts while the button is held down.
The modulo operator allows the program to return to the first prompt after reaching the end of the array. Each new prompt also resets the response timer.
Automatic Velostat Calibration
One of the most important improvements to my program was replacing the fixed textile pressure threshold with an automatically calculated threshold.
During startup, the program collects 32 analog readings from the textile sensor while it is untouched. These readings are averaged to establish the resting baseline.
The pressure threshold is then calculated as 50 percent of that baseline:
Pressure Threshold = Resting Baseline × 0.5
Because the voltage measured by my circuit decreases when pressure is applied, a reading below this threshold is interpreted as a button press.
This approach makes the program more resilient to differences in resting sensor readings and ADC scaling between sessions. However, the textile sensor must remain untouched during startup to establish a valid resting baseline.
UV Sensor Reading and Display Conversion
The UV sensor is connected to analog input A3. The program uses a 12-bit ADC resolution, providing digital readings between 0 and 4095.
The analog reading is converted into an estimated voltage using the nominal 3.3V reference:
Voltage = ADC Reading × (3.3 / 4095)
The voltage is then converted into an estimated UV index using the conversion factor implemented in my program:
Estimated UV Index = Voltage / 0.1
The drawStatus() function clears only the footer region of the display before rendering the updated UV estimate to one decimal place. Updating this region instead of redrawing the entire screen avoids unnecessary full-screen refreshes.
This UV reading is a prototype estimate rather than a calibrated scientific measurement. Its accuracy depends on the sensor characteristics, voltage reference, environmental conditions, and calibration.
Response Timer and Haptic Reminder
Each journaling prompt is assigned a response window of 20,000 milliseconds, equivalent to 20 seconds.
The program uses millis() to track the elapsed time since the current prompt was rendered. If the response window expires before the user advances to another prompt, the program calls pulseMotor() and drawReminder().
The pulseMotor() function activates the motor through its MOSFET driver for 500 milliseconds before returning the motor output to its inactive state.
The drawReminder() function displays an orange visual reminder near the bottom of the screen. The reminded variable prevents the motor and visual reminder from being repeatedly triggered for the same prompt.
Advancing to the next prompt resets both the timer and reminder state, allowing the interaction to begin again.
Continuous System Operation
During each iteration of loop(), the program reads both analog sensors, checks for a new button press, evaluates the response timer, updates the UV footer, and sends diagnostic readings to the Serial Monitor.
A 200-millisecond delay is included between loop iterations. The motor activation introduces an additional blocking delay of 500 milliseconds when the reminder is triggered.
This timing approach was sufficient for my initial prototype. Future iterations could replace the blocking delays with millis()-based timing to improve responsiveness while additional peripherals are operating.
Building: Soldering and Running Code
I connected the display using individual wires so that I could position it independently of the PCB and reuse the display module in my final console. Each wire was labeled to help prevent incorrect connections during assembly.
I temporarily insulated the individual connections using masking tape. Although this was sufficient for my initial bench prototype, the final assembly will require appropriate electrical insulation, secure connectors, and strain relief.
One of the challenges I encountered was the limited spacing between the copper pads on my previously fabricated PCB. Because the board was originally designed for the wearable portion of my final project, it did not accommodate the additional connections required by the display.
To overcome this limitation, I soldered several wires directly to the accessible microcontroller connections rather than relying exclusively on the existing copper pads.
Although this approach allowed me to complete the prototype, it highlighted the importance of designing PCBs with accessible connection points, adequate soldering clearance, and consideration for future peripheral expansion.
Bring Up Order
Staged Bring-Up and Electrical Verification
Rather than connecting all nine display wires simultaneously, I assembled and tested the circuit in stages. This reduced the number of potential failure points during troubleshooting.
- Program Upload: I uploaded the integrated Arduino sketch to the microcontroller before completing the display connections.
- Power and Ground: I established the display's power and ground connections and checked for unintended shorts using a multimeter before applying power through USB-C.
- Backlight Verification: I connected the backlight and confirmed that the display illuminated. This verified backlight operation but did not yet confirm communication with the display controller.
- SPI and Control Connections: I completed the remaining communication and control connections, checking each new solder joint before powering the circuit again.
- Continuity Testing: With the circuit disconnected from power, I checked continuity between each wire and its intended connection and checked neighboring pads for unintended electrical connections.
- Functional Verification: After completing the connections, I powered the board and verified that the programmed journaling interface appeared on the display.
This staged approach helped me distinguish between power supply issues, connection problems, and potential communication or programming errors.
Testing the Loop, Live
With all nine wires down and short-checked, I plugged in. The screen showed my prompt, the UV reading appeared along the bottom, pressing the velostat advanced to the next prompt, and after the response window elapsed the motor vibrated and the "take a moment…" nudge appeared.
I was so excited.
I recorded a screen capture of the serial pressure values changing as I pressed, alongside video of the board itself.
Functional Test Results
| Test | Expected Behavior | Observed Result | Status |
|---|---|---|---|
| Display initates, prompt renders | Render the first prompt at startup | Prompt displayed in portrait orientation | Perfect |
| UV Sensor Integration | Update the UV estimate in the display footer | UV estimate displayed and updated | Pass |
| Response Timer | Trigger a reminder after the programmed 20-second response window | Reminder appeared after the response window elapsed | Pass |
| Vibration Motor | Activate when the response window expires | Motor vibrated when the timeout occurred | Pass |
What the Serial Monitor Showed
I used the Arduino Serial Monitor at 115200 baud to observe sensor readings and verify the behavior of the integrated system during testing.
At startup, the program reports the calculated resting baseline and pressure threshold of the textile sensor. Once initialization is complete, the program continuously reports the pressure reading and estimated UV index.
Observed Sensor Readings
| Sensor | Test Condition | Observed Reading |
|---|---|---|
| UV Sensor | Indoor lighting | Approximately 0.2 estimated UV index |
| UV Sensor | Daylight exposure | Approximately 5-6 estimated UV index |
| Velostat | Resting, first testing session | 600-690 ADC counts |
| Velostat | Resting, second testing session | 770-910 ADC counts |
The variation in resting pressure readings between testing sessions reinforced the importance of establishing the textile sensor's baseline during startup rather than relying on a fixed threshold.
The UV sensor also demonstrated a measurable response to changing environmental conditions. However, these values represent estimates generated by my prototype and were not independently calibrated against a reference UV instrument.
Capturing Startup Diagnostics
The baseline, calculated threshold, and initialization messages are printed only once during setup(). Since the program continuously prints sensor readings afterward, these initial messages can quickly become difficult to locate in the Serial Monitor.
To capture the startup diagnostics, I can open the Serial Monitor and reset the microcontroller, ensuring that the textile sensor remains untouched during calibration.
Integrated Output Device Demonstration
I recorded the operation of the prototype alongside the Serial Monitor to demonstrate the relationship between sensor readings, display updates, and motor activation.
The demonstration documents the following functions:
- Initial display startup and prompt rendering.
- Prompt advancement using the textile pressure sensor.
- Estimated UV index displayed in the footer.
- Visual reminder following the programmed response window.
- Haptic feedback from the vibration motor.
This demonstration represents the successful integration of the core input and output functionality planned for my final project.
Videos
Week 10: Integrated display, textile sensor, UV sensor, and vibration motor demonstration.
Problems and Troubleshooting
Problem 1: Textile Button Threshold and ADC Resolution
The most significant programming correction I made this week involved the textile pressure sensor rather than the display itself. During Week 09, I changed the ADC resolution from 10-bit to 12-bit to accommodate the UV sensor readings, but my existing textile button threshold was based on the previous ADC scale.
| ADC Resolution | Digital Reading Range | Possible Values |
|---|---|---|
| 10-bit | 0-1023 | 1024 |
| 12-bit | 0-4095 | 4096 |
Increasing the ADC resolution changes the numerical representation of the measured voltage. Consequently, a pressure threshold established using 10-bit readings may no longer reliably identify a button press when using 12-bit readings.
My initial troubleshooting focused on adjusting the fixed threshold. However, I realized that the threshold needed to fall between the resting and pressed sensor readings rather than being tied to a specific numerical value.
Solution
I implemented automatic baseline calibration during startup. The program averages 32 resting sensor readings and calculates the pressure threshold as 50 percent of that baseline.
This allows the threshold to adapt to the sensor's resting condition each time the device powers on. The textile button must remain untouched during startup to ensure that the baseline is established correctly.
After implementing this correction, the textile button reliably advanced the journaling prompts during my testing.
Lesson Learned: Changing ADC resolution affects the numerical readings of every analog input. Calibration values should account for the measurement scale and sensor characteristics rather than relying exclusively on fixed thresholds.
Problem 2: Motor Does Not Activate When the Textile Button Is Pressed
During my initial testing, I expected the vibration motor to activate whenever I pressed the textile button because this was its behavior in my previous assignment.
When the motor did not activate, I initially suspected a wiring or programming issue. However, reviewing my updated code revealed that the motor was functioning as intended.
Solution
In the Week 10 program, the textile button advances the journaling prompt and resets the response timer. The motor is intentionally activated only when the 20-second response window expires.
When the timeout occurs, the motor activates for 500 milliseconds and the display presents a visual reminder. The reminded variable prevents repeated activation for the same prompt.
No hardware or programming correction was necessary because the observed behavior matched the intended functionality.
Lesson Learned: When troubleshooting an integrated system, it is important to verify the intended program logic before assuming that unexpected behavior indicates a hardware failure.
Problem 3: Missing Startup Diagnostics in the Serial Monitor
I encountered difficulty capturing the initial textile sensor baseline and calculated pressure threshold because these values are printed only once during setup().
Once the main program loop begins, continuous sensor readings can cause the startup messages to scroll out of view. If the Serial Monitor is not open when initialization occurs, the startup messages may also be missed.
Solution
To capture the startup diagnostics, I can open the Serial Monitor at 115200 baud and reset the microcontroller while leaving the textile sensor untouched. This restarts the initialization and calibration process.
Lesson Learned: Diagnostic messages generated during initialization serve a different purpose from continuous runtime messages. Capturing both is useful when troubleshooting embedded systems.
Problem 4: Illuminated Backlight but No Display Content
During the initial stages of assembly, the display backlight illuminated, but no text or graphics appeared on the screen. I initially questioned whether the display was functioning correctly.
Solution
I identified that the backlight operates independently of the SPI communication required by the ILI9341 display controller. At this stage of assembly, the power connections were established, but the communication and control wires had not yet been connected.
After completing the remaining connections and powering the board, the programmed journaling prompt appeared on the display.
Lesson Learned: An illuminated backlight confirms that the backlight is receiving power, but it does not independently verify display controller initialization or successful communication with the microcontroller.
Problem 5: Limited Soldering Clearance and Short-Circuit Risk
Integrating nine additional display connections into my previously fabricated PCB introduced a significant assembly challenge. The board did not have a solder mask, and the limited spacing between exposed copper pads increased the risk of unintended electrical connections.
The number of wires also increased the possibility of connecting a signal to the wrong microcontroller pin.
Solution
I managed these risks by labeling and color coding the wires, temporarily insulating exposed connections, and completing the soldering process in stages.
With the board disconnected from power, I used a multimeter to verify continuity between each wire and its intended connection. I also checked neighboring pads for unintended electrical connections before powering the system.
Lesson Learned: Electrical verification is particularly important when working with milled PCBs that lack a solder mask. Future PCB iterations should incorporate adequate pad spacing, dedicated peripheral connectors, proper insulation, and mechanical strain relief.
Assignment Reflection
This week's assignment was an important milestone in the development of MARGIN because it demonstrated the core interaction between the input and output devices planned for my final project.
By integrating the TFT display, textile pressure sensor, UV sensor, and vibration motor into my previously fabricated PCB, I was able to move beyond testing individual components and begin evaluating them as a complete interactive system.
One of my greatest takeaways was the importance of designing electronic systems with future expansion in mind. My original PCB was designed for a relatively limited number of components, and adding the display exposed limitations in pad spacing, connection accessibility, and available GPIO resources.
I also developed a better understanding of the relationship between hardware and software during troubleshooting. Several issues that initially appeared to be hardware failures were instead related to calibration, program logic, or incomplete communication connections.
Although the current prototype does not yet implement keyboard input, touchscreen interaction, or SD card storage, it establishes a functional foundation for the handheld console portion of my final project.
Moving forward, I will apply what I learned about peripheral integration, power consumption, electrical verification, and PCB layout to the next iteration of MARGIN.
Final Result
The completed Week 10 prototype demonstrates the integration of a programmed TFT display, textile pressure sensor, UV sensor, and vibration motor using my previously designed and fabricated PCB.
Files
My board's KiCad schemati and PCB layout are documented in and linked in weeks 4 and 8.