#include <Keypad.h>
#include "ssd1306.h"
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library.
// On an arduino UNO: A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
static void textDemo()
{
ssd1306_setFixedFont(ssd1306xled_font6x8);
ssd1306_clearScreen();
ssd1306_printFixed(0, 8, "Normal text", STYLE_NORMAL);
ssd1306_printFixed(0, 16, "Bold text", STYLE_BOLD);
ssd1306_printFixed(0, 24, "Italic text", STYLE_ITALIC);
ssd1306_negativeMode();
ssd1306_printFixed(0, 32, "Inverted bold", STYLE_BOLD);
ssd1306_positiveMode();
delay(3000);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ssd1306_setFixedFont(ssd1306xled_font6x8);
ssd1306_128x64_i2c_init();
// ssd1306_128x64_spi_init(-1, 0, 1); // Use this line for nano pi (RST not used, 0=CE, gpio1=D/C)
// ssd1306_128x64_spi_init(3,4,5); // Use this line for Atmega328p (3=RST, 4=CE, 5=D/C)
// ssd1306_128x64_spi_init(24, 0, 23); // Use this line for Raspberry (gpio24=RST, 0=CE, gpio23=D/C)
// ssd1306_128x64_spi_init(22, 5, 21); // Use this line for ESP32 (VSPI) (gpio22=RST, gpio5=CE for VSPI, gpio21=D/C)
// composite_video_128x64_mono_init(); // Use this line for ESP32 with Composite video support
ssd1306_clearScreen();
}
int loto=0;
char pulseStr[8]; // enough room for number and \0
void loop() {
// put your main code here, to run repeatedly:
//textDemo();
int sensorValue = analogRead(A6);
loto++;
if (loto>10) {
loto=0;
}
ssd1306_printFixed(0, 8, "Normal text" , STYLE_NORMAL);
// http://www.cplusplus.com/reference/cstdlib/itoa/?kw=itoa
itoa(loto, pulseStr, 10);
ssd1306_printFixed(0, 16, pulseStr, STYLE_NORMAL);
itoa(sensorValue, pulseStr, 10);
///display.printFixed (0, 8, pulseStr, STYLE_BOLD);
ssd1306_printFixed(0, 32, pulseStr, STYLE_NORMAL);
Serial.println(sensorValue);
delay(200);
ssd1306_clearScreen( );
}