In my previous two blogs, I learned about using ADC to detect the voltage across a variable resistor and using OLED to display some messages. So, I came up with the idea of displaying the detected voltage using the OLED.
Flow Chart:
The process is very similar to the previous one, the only difference is the second to last step, the result is printed on the OLED.

Code
from gpiozero import MCP3004
from time import sleep
from luma.core.render import canvas
from luma.oled.device import ssd1306
adc = MCP3004(channel = 0)
device = ssd1306(port = 1, address = 0x3C)
while True:
V = adc.value*3.3
with canvas(device) as draw:
draw.text((0,0), "%.2f"%V+"V", fill = "white")
sleep(0.1)
Result
By the way, it is quite interesting that there is a small black box swiping up the screen constantly, it can’t be seen by the naked eye, but my phone can detect it. It’s because phones can detect flashing images with higher frequency than our eyes.
But why is it like that?
The screen is made up of a grid of pixels, and each pixel can be independently controlled to display a specific color. However, there is a limit to the number of pixels that can be actively controlled simultaneously due to hardware constraints. This limit is typically dictated by the number of connection lines or drivers associated with each pixel. For example, if a screen has a resolution of 1920×1080 pixels, it means there are 1920 horizontal connection lines and 1080 vertical connection lines, resulting in a total of 1,920,000 pixels. However, only a subset of these pixels can be actively controlled at any given time due to the limitations in hardware.
The number of pixels that can be lit simultaneously is limited by the bandwidth and processing power of the screen’s controller. If too many pixels are lit simultaneously, the controller may not be able to keep up with the demand, leading to performance issues such as ghosting or lagging. Therefore, to achieve a smooth and responsive visual experience, some pixels are lit in the first segment of time, and some pixels are lit during the next. As long as the frequency is greater than the maximum frequency that the human eye can distinguish, which is about 25 Hertz.