10. Output Devices¶
Individual Assignment¶
- Add an output device to a microcontroller board you’ve designed and program it to do something.
OLED¶
This is my PCB design:
This is my soldered PCB:
When testing the PCB, I initially struggled with getting the screen to light up and display a message, so I used ChatGPT to help troubleshoot. It turns out my mistake was the pinout. I forgot to double check the pinout for the SDA and SCL pins, and once I fixed that, it worked seamlessly.
I used this code to find the screen and troubleshoot:
#include <Wire.h>
#define SDA_PIN 8 // D10
#define SCL_PIN 9 // D9
void setup() {
Wire.begin(SDA_PIN, SCL_PIN);
Serial.begin(115200);
delay(1000);
Serial.println("I2C Scanner");
for (byte address = 1; address < 127; ++address) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) {
Serial.print("Device found at 0x");
Serial.println(address, HEX);
}
}
Serial.println("Scan complete.");
}
void loop() {}
This is the output in the serial monitor from that code:
This is the code I used to display a message on the screen:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Display dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// OLED reset pin (not used with I2C)
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
// I2C pins for XIAO ESP32S3
#define SDA_PIN 8 // D10
#define SCL_PIN 9 // D9
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Serial.begin(115200);
delay(500); // Wait for Serial Monitor
Wire.begin(SDA_PIN, SCL_PIN);
// Initialize OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("OLED init failed"));
while (true); // Stop execution if OLED not found
}
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Hello!");
display.display();
}
void loop() {
// Do nothing
}
This is my final lit up screen:
Group Assignment¶
Our group assignment for this week was to measure the power consumption of an output device. I worked with Kathryn Wu and Jenna Chebaro this week. Here is a link to our group page for this week.
Reflection¶
This week was not very difficult although I did run into a few challenges. I am pleased with how easy the screen is to control now that I understand it, and this will definitely come in handy with my final project and the screen component of my final project.
AI Help¶
Here are all my ChatGPT searches from Week 10: PDF