/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial:
Wire library
Adafruit_GFX library
Adafruit_SSD1306 library
Tutorial: How to display text on OLED display with Arduino!
The function of this sketch is to display some words and variables on the OLED display screen.
You can print your name on the screen and print some dots on the screen in different pixels,
which enables you to draw curves later.
Connections from the OLED Display to arduino :
OLED VCC PIN → Arduino 5V pin
OLED GND PIN → Arduino GND pin
OLED SDA PIN → Arduino pin A4
OLED SCL PIN → Arduino pin A5
*/
#include "SPI.h"
#include "Wire.h"
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
int a=1; // global variable
void setup() {
Serial.begin(9600);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x64)
display.clearDisplay(); // Clear the buffer.
display.setTextSize(2); // You can select text size ex- 1, 2, 3 and so on
display.setTextColor(WHITE); // This will display Bright character on Black background
display.setCursor(5,0); // You are setting the cursor as per your requirement. In short its the co-ordinates in display from where data will display
display.println("voltaat"); // String which you are printing
display.setTextSize(1);
display.setTextColor(BLACK, WHITE); // Here you print 'Black character' on 'Bright Background'
display.setCursor(12,25);
display.println("www.voltaat.com");
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(13,44);
display.println("voltaat team");
display.display(); // this command will display all the data which is in buffer
delay(2000);
display.clearDisplay(); // clear the buffer
}
void loop() {
display.clearDisplay();
if(a>10){a=0;} // This loop will make counter 0 again after reaching maximum value 10
display.drawPixel(127, 63, WHITE); // This command will help you to print a pixel on display , its the last pixel, coordinate 127,63
display.drawPixel(0, 0, WHITE); // pixel with 0,0 coordinate
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(13,44);
display.println("voltaat");
display.setCursor(10,0);
display.setTextSize(2);
display.println(a); // printing a variable
a++; // incriment in variable a
display.display();
delay(1000);
}