Turn OLED DIsplay on and Off With a Push Button Using Arduino

by RonFrtek in Circuits > Arduino

424 Views, 1 Favorites, 0 Comments

Turn OLED DIsplay on and Off With a Push Button Using Arduino

Turn OLED DIsplay On and Off With a Push Button Using Arduino

In this tutorial we are going to Turn ON or OFF the OLED Display using a button & Arduino.

Watch the Video!

What You Will Need

oled.jpg
mini_push_button.1471344052-600x435.png
resistor-1k-ohm-14w-5.jpg
breadboard.png
VisuinoAdvrtisemenESPNowESP32C3-1.jpg
jumper-wires.jpg
FZEK4WBK3XGYAP0.LARGE.jpg
  • Arduino UNO (or any other Arduino or ESP)
  • OLED I2C Display
  • 1K ohm resistors
  • LED
  • Button
  • Jumper wires
  • Breadboard
  • Visuino program: Download Visuino


The Circuit

2022-10-01_14-41-58.jpg
  • Connect OLED Display pin [SCL] to Arduino pin [SCL]
  • Connect OLED Display pin [SDA] to Arduino pin [SDA]
  • Connect OLED Display pin [VCC] to the breadboard positive pin [5V]
  • Connect OLED Display pin [GND] to the breadboard pin [GND]
  • Connect Arduino Digital pin [4] to the Resistor and button
  • Connect other side of the resistor to the breadboard pin [GND]
  • Connect Other pin of the button to the breadboard positive pin [5V]


Start Visuino, and Select the Arduino UNO Board Type

FRWQB80K1RVKKV9.LARGE.jpg
Visuino-Select-Board-UNO.jpg

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add Components

2022-10-01_11-36-04.jpg
2022-10-01_11-36-45.jpg
2022-10-01_11-37-14.jpg
  • Add "Debounce Button" component
  • Add "Toggle(T) Flip-Flop" component
  • Add "OLED I2C" component


In Visuino Set Components

2022-10-01_11-42-22.jpg
2022-10-01_11-37-29.jpg
2022-10-01_11-37-45.jpg
2022-10-01_11-38-46.jpg
  • Select "DisplayOLED1" and in the properties window select "Power On" and click on the pin icon and select "Boolean SinkPin"
  • Double click on the "DisplayOLED1" and in the "Elements" window drag "Draw Text" to the left and in the properties window set "Text" to ARDUINO and "Size" to 3
  • Close the "Elements" window
  • Select "TFlipFlop1 and in the properties window set "Initial Value" to False

In Visuino Connect Components

2022-10-01_11-36-20.jpg
  • Connect Arduino digital pin[4] to "Button1" pin [In]
  • Connect "Button1" pin [Out] to "TFlipFlop1" pin [Clock]
  • Connect "TFlipFlop1" pin [Out] to "DisplayOLED1" pin [Power On]
  • Connect "DisplayOLED1" pin I2C [Out] to Arduino pin I2C [In]


Generate, Compile, and Upload the Arduino Code

FBR42I2KXBU01YW.jpg

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Play

If you power the Arduino module, The Display will show the Text, if you press the button, the Display will Turn On or Off.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this tutorial, you can download it and open it in Visuino: https://www.visuino.eu