Using Wemos D1 Mini & Oled Shield

Category : Arduino, Electronics

In this guide I’ll show you how to use the shield and it’s two buttons. Lets get to it.

Resoltion is 64×48
Button A is by default pin D3.
Button B is by default pin D4.

Buttons can be customized by soldering jumper pads under the shield.

Parts:

Wemos D1 Mini @ Aliexpress

Oled Shield @ Aliexpress

PS, be sure to get the shield with A & B buttons when you buy it, there are a few types to choose from.

Code:

There are several libraries to choose from, but I found the one from Sparkfun to be suitable for my use.

Download it, then unzip in libraries folder and restart Arduino IDE. Then paste my code:

#include <Wire.h>  // Include Wire if you're using I2C
#include <SFE_MicroOLED.h>  // Include the SFE_MicroOLED library
 
#define PIN_RESET 255  //
#define DC_JUMPER 0  // I2C Addres: 0 - 0x3C, 1 - 0x3D
 
MicroOLED oled(PIN_RESET, DC_JUMPER); // Example I2C declaration
 
void setup()
{
  // Before you can start using the OLED, call begin() to init
  // all of the pins and configure the OLED.
  oled.begin();
  // clear(ALL) will clear out the OLED's graphic memory.
  // clear(PAGE) will clear the Arduino's display buffer.
  oled.clear(ALL);  // Clear the display's memory (gets rid of artifacts)
 
  pinMode(D4, INPUT); // Setting D4 B Button as input
  pinMode(D3, INPUT); // Setting D3 A Button as input
}
 
void loop()
{
  oled.clear(PAGE);     // Clear the screen
  oled.setFontType(0);  // Set font to type 0
  oled.setCursor(0, 0); // Set cursor to top-left
  oled.print("Line 1");
  oled.setCursor(0, 8); // Set cursor to top-left
  oled.print("Line 2");
  oled.setCursor(0, 16); // Set cursor to top-left
  oled.print("Line 3");
  oled.setCursor(0, 24); // Set cursor to top-left
  oled.print("Line 4");
  oled.setCursor(0, 32); // Set cursor to top-left
  oled.print("Line 5");
  oled.setCursor(0, 40); // Set cursor to top-left
  oled.print("Line 6");
 
 
  if (digitalRead(D4) == LOW)
  {
    oled.setCursor(0, 40); // Set cursor to top-left
    oled.print("B Pushed");
 
  }
 
  if (digitalRead(D3) == LOW)
  {
    oled.setCursor(0, 32); // Set cursor to top-left
    oled.print("A Pushed");
 
  }
  oled.display();
}

You should now see this when buttons are pressed: