Demonstrates the use of 128x64 I2C OLED and DS 1302 RTC to display date and time. You can download OLED I2C and DS1302 library at Rinky-Dink Electronic.
- Arduino Uno
- 128x64 I2C OLED
- Pushbutton
- RTC DS1302
- Wire Jumper
Video
Coding
#include <OLED_I2C.h>
#include <DS1302.h>
OLED myOLED(SDA, SCL, 8);
DS1302 rtc(2, 3, 4);
extern uint8_t SmallFont[];
void setup()
{
myOLED.begin();
myOLED.setFont(SmallFont);
rtc.halt(false);
rtc.writeProtect(false);
rtc.setDOW(FRIDAY);
rtc.setTime(12, 0, 0);
rtc.setDate(6, 8, 2010);
}
void loop()
{
myOLED.clrScr();
myOLED.print(rtc.getTimeStr(), CENTER, 0);
myOLED.print(rtc.getDOWStr(FORMAT_SHORT), CENTER, 24);
myOLED.print(rtc.getDateStr(), CENTER, 50);
myOLED.update();
delay(1000);
}
Hello, very interesting simple and fast, and its working out of the box.
ReplyDeleteBut i have question, how to do it for attiny85? (i mean this code)