This shows you the differences between two versions of the page.
|
pm:prj2023:danield:ceas-luminos [2023/05/21 23:40] andreea.badescu [Hardware Design] |
pm:prj2023:danield:ceas-luminos [2023/05/29 23:53] (current) andreea.badescu [Software Design] |
||
|---|---|---|---|
| Line 31: | Line 31: | ||
| ===== Software Design ===== | ===== Software Design ===== | ||
| + | #include <Wire.h> | ||
| + | #include <LiquidCrystal_I2C.h> | ||
| + | #include <DS3231.h> | ||
| + | #define red 9 | ||
| + | #define green 10 | ||
| + | #define blue 11 | ||
| + | int brightness = 50; | ||
| + | int fadeAmount = 5; | ||
| + | LiquidCrystal_I2C lcd(0x27,16,2); | ||
| + | |||
| + | // Init the DS3231 using the hardware interface | ||
| + | DS3231 rtc(SDA, SCL); | ||
| + | |||
| + | //alarma | ||
| + | int h_alarm= 22; | ||
| + | int m_alarm = 3; | ||
| + | |||
| + | void setup() { | ||
| + | lcd.init();// initialize the lcd | ||
| + | lcd.backlight();//open the backlight | ||
| + | rtc.begin(); | ||
| + | //rtc.setTime(10,53,0); | ||
| + | //rtc.setDate(29,05,2023); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | lcd.setCursor(0, 0); | ||
| + | lcd.print("TIME ~ " ); | ||
| + | lcd.print(rtc.getTimeStr()); | ||
| + | lcd.setCursor(0, 1); | ||
| + | lcd.print("DATE ~ "); | ||
| + | lcd.print(rtc.getDateStr()); | ||
| + | delay (1000); | ||
| + | lcd.clear(); | ||
| + | if(h == h_alarm && m == m_alarm) | ||
| + | { | ||
| + | analogWrite(red, brightness); | ||
| + | analogWrite(green, brightness); | ||
| + | analogWrite(blue, brightness); | ||
| + | brightness = brightness + fadeAmount; | ||
| + | if(brightness <=0 || brightness >= 255) | ||
| + | { | ||
| + | fadeAmount = -fadeAmount; | ||
| + | } | ||
| + | delay(500); | ||
| + | } | ||
| + | } | ||
| <note tip> | <note tip> | ||