IoT 4 - Display & PWM

2 min read

IoT 4 - Display & PWM

I’m continuing my project, and this week we’re focusing on displays and actuators.

I’m continuing my project, and this week we’re focusing on displays and actuators. Let’s begin!


1. Display

Displays are used to display information from embedded systems. There are various types of displays; this time, I’ll be using an OLED.

Here’s the wiring I’m using:

Article screenshot: iot 4 1

Type "SSD1306" in the search box and install all of the SSD1306 library’s dependencies from Adafruit.

Next, let’s move on to the code in the Arduino IDE. First, open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The Library Manager should open.

Article screenshot: iot 4 2

The Adafruit library for the OLED display comes with several functions for writing text. I’ll write "Hello World" in it as an example. This is the code I’m using.

Article screenshot: iot 4 3

Source: https://randomnerdtutorials.com/esp32-ssd1306-oled-display-arduino-ide/

After uploading the code, this is what you’ll get in the OLED:

Article screenshot: iot 4 4

Because I was bored, I wanted to display my favorite character—Asa Mitaka—on the OLED. I used an Image to C Array converter for this. To make it happen, I put the C header file and the Arduino file in the same folder. Don’t forget to include the header.

This is the Arduino code I used:

Article screenshot: iot 4 6

Yeah, done!!! Here’s the result.

Article screenshot: iot 4 7


2. PWM

Next, I’ll experiment with PWM using LED lights. PWM is a technique for obtaining an analog signal from a digital system; this technique can be used to control the brightness of an LED.

Here’s the wiring configuration of mine.

Article screenshot: iot 4 8

This is the code I used.

Article screenshot: iot 4 9

Source: https://randomnerdtutorials.com/esp32-pwm-arduino-ide/