I just started using this display today and I'm trying to display the time (specifically the hour) using this code but for some reason it doesn't display the hour. Help please.
#include <Time.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
//for the time libary
char dahour[2];
char daminute[20];
char daday[3];
char damonth[4];
char dayear[15];
char dasecond[12];
void digitalClockDisplay(){
Serial.print(hour());
Serial.print(minute());
Serial.print(second());
Serial.print(day());
Serial.print(month());
Serial.print(year());
Serial.println();
}
void setup() {
Serial.begin(9600);
setTime(17,3,0,10,19,13);
// 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 0x3D (for the 128x64)
// init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
// draw a single pixel
display.drawPixel(10, 10, WHITE);
// Show the display buffer on the hardware.
// NOTE: You _must_ call display after making any drawing commands
// to make them visible on the display hardware!
display.display();
delay(2000);
display.clearDisplay();
testscrolltext();
delay(2000);
display.clearDisplay();
chickensoup();
delay(2000);
display.clearDisplay();
}
void testscrolltext(void) {
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(10,8);
display.clearDisplay();
display.println("The time is");
display.display();
}
void chickensoup(void) {
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(40,20);
display.clearDisplay();
display.print(dahour);
display.display();
}
void loop() {
}