Its been years since i played with an Arduino (Arrival of children have slowed down projects
) so thought i could get back in the game with a project for my children. a sun rise clock to show when its time to get up. I Found a project online that was perfect for my needs
The only diffrence was that i have a DS3231 RTC spare and not the DS1307 so i change out the library no problems there but i keep receiving a error that i cant get my brain around
C:\Users\Yeti\Documents\Arduino\ClockSunshine\ClockSunshine.ino: In function 'void setup()':
ClockSunshine:24: error: 'RTC' was not declared in this scope
 setSyncProvider(RTC.get);Â
         ^
exit status 1
'RTC' was not declared in this scope
how would i declare this in my code bellow, thank you again for any help that anyone can give
#include <Time.h>
#include <TimeLib.h>
#include <Wire.h>
#include <RtcDS3231.h>
#include <TimeAlarms.h>
#include <FastLED.h>
#define NUM_LEDS 16
#define DATA_PIN 2
CRGB leds[NUM_LEDS];
CRGB OffColour = CRGB(0, 1, 2);
CRGB OnColour = CRGB(16, 8, 0);;
void setup()Â
{
 //Create a time struct with the alarm time
 tmElements_t tm;
 tm.Hour = 7;
 tm.Minute = 0;
 tm.Second = 0;
Â
 // Get the time from the rtc
 setSyncProvider(RTC.get);Â
Â
 // Initialise the LEDs in the ring
 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
 //Used to test by setting the time to now + 5 seconds
 RTC.read(tm);
 tm.Second += 5;
Â
 //Create an alarm for the morning
 Alarm.alarmOnce(tm.Hour, tm.Minute, tm.Second, LightsOn);Â
 Â
 //Create an alarm an hour later to turn the lights off again
 Alarm.alarmOnce(tm.Hour + 1, tm.Minute, tm.Second, LightsOff);Â
Â
 // Set the initial colour of the LED's
 LightsOff();
}
void loop()
{
 // Alarm.delay has to be called occasionally to make the alarms work
 Alarm.delay(500);
}
//Create a sunrise style effect
void LightsOn()
{
 for(int i = 0; i < NUM_LEDS / 2; i += 1)
 {Â
  leds[i] = OnColour;
  leds[NUM_LEDS - i - 1] = OnColour;
  FastLED.show();
  Alarm.delay(500);
 }
}
//Set the LED's all to the off colour
void LightsOff()
{
 for(int i = 0; i < NUM_LEDS; i += 1)
  leds[i] = CRGB(0, 1, 2);
 FastLED.show();
}
ClockSunshine.ino (1.37 KB)