Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod OLED with Arduino Uno

Application notes for Pmod OLED and Arduino Uno. In this app, a cloud of points is displayed randomly, then a flashing message will appear.

BeginnerShowcase (no instructions)1 hour3,344
Using the Pmod OLED with Arduino Uno

Things used in this project

Story

Read more

Schematics

Pmod OLED and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod OLED to the Arduino Uno.

Pmod OLED and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod OLED and Arduino Uno.

Code

Pmod OLED and Arduino Uno Code

Arduino
Using this code will display a cloud of random points on the Pmod OLED before flashing a message 3 times.
/************************************************************************
*
* Test of the Pmod 
*
*************************************************************************
* Description: Pmod_OLED
* A cloud of points is displayed randomly
* then the Message lextronic appears and flashes 3 times.
*
* Material
* 1. Arduino Uno
* 2. Pmod OLED
* (Download libraries https://github.com/adafruit/Adafruit_SSD1306 et
* https://github.com/adafruit/Adafruit-GFX-Library)
*
************************************************************************/

// Affectation of pins
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13

// Call of libraries
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SPI.h>

Adafruit_SSD1306 afficheur(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
//creation of object

int x;
int y;

void setup(void)
{
 afficheur.begin(); // initialization of display object
 afficheur.display(); // refresh display
 afficheur.clearDisplay(); // erase display
 afficheur.display(); // refresh display
}

void loop()
{
 afficheur.clearDisplay(); // erase display
 afficheur.display(); // refresh display
 for (int i=0; i <= 50; i++) // display cloud of points
 {
  x=random(128); // x take random value from 0 to 128
  y=random(32); // y take random value from 0 et 32
  afficheur.drawPixel(x, y, WHITE); // Display pixel at (x,y)
  afficheur.display(); // refresh display
  delay(50); // wait 50 ms
 }
 afficheur.setTextSize(2); // configuration of size of caracters caractères
 afficheur.setTextColor(WHITE);
 afficheur.setCursor(10,10); // set cursor at x=10 and y=10
 afficheur.println("LEXTRONIC"); // display LEXTRONIC
 afficheur.display(); // refresh display
 delay(1000);
 for (int i=0; i <= 3; i++) // the message blink
 {
  afficheur.setCursor(10,10);
  afficheur.println("LEXTRONIC");
  afficheur.display();
  delay(1000);
  afficheur.clearDisplay();
  afficheur.display();
  delay(500);
 }
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 18 followers
Alex Wong

Alex Wong

14 projects • 53 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments