hello...
I'm totally new to arduino and I have a project to hand next week
my goal to accoplishe is to use arduino as alarm clock that turn on light on specific time
I searched solutions online, most on this forum, but I can't connect it all
firs idea was that computer send real time to arduino that is displayed on lcd (it's working fine), but after failure I decided to use code from internet that allows to set up time and than counts
a problem is now to start led when desirable time is reached, by chance to slowly start up, opposite of dimming (example)
code I used so far:
#include <LiquidCrystal.h>
#include <DateTime.h>
// simple sketch to display a digital clock on an LCD
// see the LiquidCrystal documentation for more info on this
LiquidCrystal lcd(7,8,9,10,11,12);
int ledPin = 13; // LED connected to digital pin 13
void setup(){
//DateTime.sync(1230768000); // set jan 1 2009 as the default time
DateTime.sync(DateTime.makeTime(0, 40, 10, 29, 5, 2010));
}
void loop(){
if(DateTime.available()) {
unsigned long prevtime = DateTime.now();
while( prevtime == DateTime.now() ) // wait for the second to rollover
;
DateTime.available(); //refresh the Date and time properties
digitalClockDisplay( ); // update digital clock
}
}
void printDigits(byte digits){
// utility function for digital clock display: prints preceding colon and leading 0
lcd.print(":");
if(digits < 10)
lcd.print('0');
lcd.print(digits,DEC);
}
void digitalClockDisplay(){
lcd.home();
// digital clock display of current time
lcd.print(DateTime.Hour,DEC);
printDigits(DateTime.Minute);
printDigits(DateTime.Second);
}
time_t alarmOnTime = (10 * SECS_PER_HOUR) + (45 * SECS_PER_MIN);
time_t alarmOffTime = alarmOnTime + (60 * SECS_PER_MIN);
time_t nextAlarm;
nextAlarm = previousMidnight(DateTime.now())+ alarmOffTime;
if ( DateTime.now() >= alarmOnTime && DateTime.now() < alarmOnTime + alarmOffTime ){
digitalWrite(ledPin), HIGH);
}
else{
digitalWrite(ledPin), LOW);
}
but error occur
any suggestion is appreciated
(my C programming is in basics =/)