Project #3 – LCD Shield – Mk3
2 X Jumper Wires Premium 3″ M/M
1 X Project #3 – LED Shield – Mk2
LCDShieldMk3.0.ino
// ***** Don Luc ***** // Software Version Information // 3.0 // include the library code: #include <Wire.h> #include <Adafruit_MCP23017.h> #include <Adafruit_RGBLCDShield.h> #include <SPI.h> #include <RTClib.h> #include <RTC_DS3231.h> RTC_DS3231 RTC; #define SQW_FREQ DS3231_SQW_FREQ_1024 //0b00001000 1024Hz Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield(); // These #defines make it easy to set the backlight color #define OFF 0x0 #define RED 0x1 #define YELLOW 0x3 #define GREEN 0x2 #define TEAL 0x6 #define BLUE 0x4 #define VIOLET 0x5 #define WHITE 0x7 boolean isChorno = false; char datastr[100]; void loop() { // timeChrono(); timeChrono(); uint8_t momentaryButton = RGBLCDShield.readButtons(); if ( momentaryButton ) { RGBLCDShield.clear(); RGBLCDShield.setCursor(0,0); if ( momentaryButton & BUTTON_UP ) { RGBLCDShield.print("GREEN - UP"); RGBLCDShield.setBacklight(GREEN); } if ( momentaryButton & BUTTON_DOWN ) { RGBLCDShield.print("RED - DOWN"); RGBLCDShield.setBacklight(RED); } if ( momentaryButton & BUTTON_LEFT ) { RGBLCDShield.print("BLUE - LEFT"); RGBLCDShield.setBacklight(BLUE); } if ( momentaryButton & BUTTON_RIGHT ) { RGBLCDShield.print("YELLOW - RIGHT"); RGBLCDShield.setBacklight(YELLOW); } if ( momentaryButton & BUTTON_SELECT ) { RGBLCDShield.print("OFF"); RGBLCDShield.setBacklight(OFF); } } delay(3000); }
setup.ino
void setup() { // set up the LCD's number of columns and rows: RGBLCDShield.begin(16, 2); RGBLCDShield.print("Don Luc!!!"); RGBLCDShield.setBacklight(VIOLET); // ChronoDot setupChrono(); }
ChronoDot.ino
void setupChrono() { RTC.begin(); DateTime now = RTC.now(); DateTime compiled = DateTime(__DATE__, __TIME__); RTC.getControlRegisterData( datastr[0] ); } void timeChrono() { DateTime now = RTC.now(); DateTime isNow (now.unixtime() + 5572 * 86400L + 26980); // set the cursor to column 0, line 1 RGBLCDShield.setCursor(0, 1); if ( isChorno == false ) { isChorno = true; RGBLCDShield.print(isNow.year(), DEC); RGBLCDShield.print('/'); RGBLCDShield.print(isNow.month(), DEC); RGBLCDShield.print('/'); RGBLCDShield.print(isNow.day(), DEC); RGBLCDShield.print(' '); RGBLCDShield.print(' '); } else if ( isChorno == true ) { isChorno = false; RGBLCDShield.print(isNow.hour(), DEC); RGBLCDShield.print(':'); RGBLCDShield.print(isNow.minute(), DEC); RGBLCDShield.print(':'); RGBLCDShield.print(isNow.second(), DEC); RGBLCDShield.print(' '); RGBLCDShield.print(' '); } }
Don Luc
Leave a Reply