Created
October 28, 2017 23:38
-
-
Save rveitch/093259a5388d0c8aca9bc07404e45737 to your computer and use it in GitHub Desktop.
Particle Photo w/ LCD - Clock Example Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Adafruit_SSD1306.h" | |
| /**************************************************** | |
| The connection of the OLED to my Particle Photon is | |
| VCC = 3.3V | |
| GND = GND | |
| SCL = A5 / D1* | |
| SDA = A4 / D0* | |
| ****************************************************/ | |
| /* ============== MAIN =====================*/ | |
| //Use I2C with OLED RESET pin on D4 | |
| #define OLED_RESET D4 | |
| Adafruit_SSD1306 oled(OLED_RESET); | |
| unsigned long previousMillis; | |
| unsigned long interval = 30000; | |
| void setup() { | |
| // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) | |
| oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) | |
| // init done | |
| //oled.display(); // show splashscreen | |
| Time.zone(-5); | |
| } | |
| void loop() { | |
| oled.clearDisplay(); | |
| delay(200); | |
| oled.setTextSize(2); | |
| oled.setTextColor(WHITE); | |
| oled.setCursor(0,0); | |
| oled.print(Time.hourFormat12()); oled.print(":"); oled.print(Time.minute()); oled.print(":"); oled.print(Time.second()); | |
| oled.setTextColor(BLACK, WHITE); // 'inverted' text | |
| oled.display(); | |
| delay(800); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment