10. Output Devices

This week I used my Everything Bagel Board to light up a LCD screen with messages I communicate via Arduino IDE Serial Monitor.

Research

I have a lot of experience using the Arduino IDE and the Serial Monitor function, but I usually use it to monitor my electronics and check if my components are working. Typically, I have my input devices communicate data to the Serial Monitor.

For Output Devices Week, I wanted to try something different. Instead of just reading from the Serial Monitor, I wanted to send messages through it and have them displayed on my chosen output device. I chose to use an LCD screen because I wanted to see my messages appear in real time.

Measuring Power Consumption

Power Equation: P = V × I

To determine the power consumption of our servo motor, we measured both the voltage and current in two different states: while the motor was running normally and while it was manually stalled. To measure current accurately, we placed the multimeter in series with the motor in the circuit.

We discovered that the stalled motor consumed significantly more power—approximately 100 times more than when it was running normally. This is because the current draw (represented by I in the power equation) increases substantially when the motor is unable to rotate. A stalled motor can pose a risk to the microcontroller by drawing excessive current over time, potentially leading to overheating or failure.

State Voltage (V) Current (A) Power (W)
Not Stalled 4.926 V 0.078 A 0.384 W
Stalled 4.32 V 0.3869 A 1.67 W

Setting up LCD Screen

The first part of this process was soldering an LCD backpack to the back of the LCD screen and adjusting the brightness settings. I also had to connect the LCD screen to my microcontroller board and make sure it was powered correctly.

I used my custom board that I designed from Electronics production week, which is an Everything Bagel Board which was designed to have lots of pin headers and easy access to power/GND. It's like reinventing the Arduino Uno.

You can learn more about how I made this board here.

I ran wires from ground to ground, power to power, and connected the SDA and SCL lines to their corresponding pins on my board.

Once the screen was plugged in and powered on, I noticed that the text was barely visible unless I tilted the screen at an angle. After looking into the issue online, I found out that the LCD screen has a built-in potentiometer on the back for adjusting contrast. I used a screwdriver to gently turn the dial, cycling through different brightness levels—from completely blank to fully lit white blocks. I adjusted it until the text was crisp and perfectly visible.

Creating the Code

Once everything was set up, I had to create a program. My intention this time around was to make the message I typed into the Serial Monitor appear differently on the LCD screen. I thought of something both funny and meaningful—I wanted to type “I hate you” and “you’re stupid” into the Serial Monitor, and have the display automatically clean up the message to say, “I love you” and “you’re kind.”

I think we need more kindness in the world, and this project was a fun way to promote that. I’m tired of hearing people say mean things, so as the controller and programmer this week, I decided to make everyone think more positively.

Once I had the idea, I used ChatGPT to help me create the code. After setting the parameters, I uploaded the program to the Arduino IDE and flashed it to my microcontroller. I made sure to download the necessary LCD library so the screen could interpret the commands—without that, the code wouldn’t work properly.

#include < Wire.h> #include < LiquidCrystal_I2C.h> // Initialize LCD (16 columns, 2 rows) LiquidCrystal_I2C lcd(0x27, 16, 2); String inputText = ""; void setup() { Serial.begin(9600); lcd.init(); lcd.backlight(); Serial.println("Type a message. Words like 'hate' and 'stupid' will be replaced."); } void loop() { if (Serial.available() > 0) { inputText = Serial.readStringUntil('\n'); // Convert to lowercase for easier filtering String processedText = inputText; processedText.toLowerCase(); // Replace "hate" with "love" processedText.replace("hate", "love"); // Replace "stupid" with "kindness" processedText.replace("stupid", "kindness"); // Display on LCD lcd.clear(); lcd.setCursor(0, 0); lcd.print(processedText.substring(0, 16)); // Line 1 if (processedText.length() > 16) { lcd.setCursor(0, 1); lcd.print(processedText.substring(16, 32)); // Line 2 } Serial.println("Cleaned message displayed on LCD:"); Serial.println(processedText); } }

Once the library was installed, I tested the program by typing “I hate you” into the Serial Monitor, and sure enough, it replaced the message with “I love you.” I felt warm and fuzzy inside.

I tried again with “you’re stupid,” and it correctly changed it to “you’re kind.” This made me feel happy and successful. I ran a few more tests and noticed something beautiful—when I typed “I love you” into the Serial Monitor, it didn’t change it to anything negative. It simply displayed the message exactly as I typed it. Wow. That is so kind.

Final

• • • Group Documentation on Safety Procedures