Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Required libraries: http://www.rinkydinkelectronics.com/library.php?id=5
- https://code.google.com/p/u8glib/
- Blog Post: http://overskill.alexshu.com/ds1302-real-time-clock-w-arduino/
- */
- #include "U8glib.h"
- #include <DS1302.h>
- DS1302 rtc(2, 3, 4);
- U8GLIB_ST7920_128X64 u8g(13, 11, 12, U8G_PIN_NONE);
- void draw(void) {
- u8g.setFont(u8g_font_04b_03);
- u8g.drawStr( 20, 10, "AquaTank Control V2");
- u8g.drawStr( 48,20, rtc.getTimeStr());
- u8g.drawStr( 40,30, rtc.getDOWStr());
- u8g.drawStr( 43,40, rtc.getDateStr());
- u8g.drawStr( 17,55, "DS1302 Real Time Clock");
- }
- void setup(void) {
- rtc.halt(false);
- rtc.writeProtect(false);
- // rtc.setDOW(WEDNESDAY); // Set Day-of-Week to FRIDAY
- // rtc.setTime(11, 40, 0); // Set the time to 12:00:00 (24hr format)
- // rtc.setDate(9, 4, 2014); // Set the date to August 6th, 2010
- // assign default color value
- if ( u8g.getMode() == U8G_MODE_R3G3B2 )
- u8g.setColorIndex(255); // white
- else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
- u8g.setColorIndex(3); // max intensity
- else if ( u8g.getMode() == U8G_MODE_BW )
- u8g.setColorIndex(1); // pixel on
- }
- void loop(void) {
- // picture loop
- u8g.firstPage();
- do {
- draw();
- } while( u8g.nextPage() );
- // rebuild the picture after some delay
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement