This shows you the differences between two versions of the page.
pm:prj2023:danield:ceas-luminos [2023/05/08 22:19] andreea.badescu |
pm:prj2023:danield:ceas-luminos [2023/05/29 23:53] (current) andreea.badescu [Software Design] |
||
---|---|---|---|
Line 16: | Line 16: | ||
===== Hardware Design ===== | ===== Hardware Design ===== | ||
- | * Arduino | + | * Arduino Uno |
- | * Ecran LCD | + | * Ecran LCD |
* Breadboard | * Breadboard | ||
* Modul RTC | * Modul RTC | ||
- | * Mosfet | + | * 3 Tranzistoare TIP122 |
- | * Led | + | * Banda LED |
- | * Glob | + | * Glob de plastic |
+ | * Rezistente 1k | ||
+ | * Butoane | ||
+ | * Modul Bluetooth HC-05 | ||
+ | * Alimentator 12V | ||
+ | * Potentiometru | ||
+ | {{ :pm:prj2023:danield:circuit_hardware_ceas_luminos.jpg?300 |}} | ||
===== 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> |