di2tnugraha
Published © GPL3+

DIY Cool Watch

Create a cool watch with Arduino.

IntermediateProtip1,182
DIY Cool Watch

Things used in this project

Story

Read more

Schematics

DIY Cool SmartWatch

Arduino oled connection m8afmz0nwi

Code

OLEDRTC.ino

Arduino
//by: di2tnugraha
#include <Wire.h>
#include <DS3231.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
DS3231 clock;
RTCDateTime dt;

void setup()
{
  Serial.begin(9600);
  // Initialize DS3231
  Serial.println("Initialize DS3231");;
  clock.begin();
  // Set sketch compiling time
  clock.setDateTime(__DATE__, __TIME__);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 
  display.display();
  delay(2000);
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(0,0);
  display.println("KENZIE");
  display.println("CHANNEL");
  display.display();
  delay(3000);
}

void loop()
{
  dt = clock.getDateTime();

  display.clearDisplay();
  Serial.println(clock.dateFormat("H:i:s", dt));
    // text display tests
  display.setTextSize(3.5);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(10,0);  
  display.print(clock.dateFormat("H:i", dt));
  display.display();

  display.setTextSize(2);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(104,0);  
  display.print(clock.dateFormat("s", dt));
  display.display();

  Serial.println(clock.dateFormat("D d-M-y", dt));
  display.setTextSize(1);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(15,25);
  display.println(clock.dateFormat("D, d M Y", dt));
  display.display();

  delay(1000);
}

Credits

di2tnugraha

di2tnugraha

3 projects • 4 followers

Comments

Add projectSign up / Login