Bin jetzt dabei, hat auch alles soweit geklappt, bis ich versucht habe TimeAlarms einzurichten.
ich bekomme folgenden Fehler
/Users/louisbindernagel/Documents/Arduino/TEst_LCD/Fertig1/Fertig1.ino: In function 'void setup()':
Fertig1:25: error: 'RelayOn' was not declared in this scope
Alarm.alarmRepeat(20,30,0, RelayOn);
^
Fertig1:26: error: 'RelayOff' was not declared in this scope
Alarm.alarmRepeat(20,35,0, RelayOff);
^
/Users/louisbindernagel/Documents/Arduino/TEst_LCD/Fertig1/Fertig1.ino: In function 'void digitalClockDisplay()':
Fertig1:67: error: variable or field 'RelayOn' declared void
void RelayOn(RELAY1, LOW) {
^
exit status 1
'RelayOn' was not declared in this scope
bei diesem Code
#include <TimeAlarms.h>
#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
AlarmId id;
#define RELAY1 7
void setup(void)
{
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
lcd.begin(16, 2);
Alarm.alarmRepeat(20,30,0, RelayOn);
Alarm.alarmRepeat(20,35,0, RelayOff);
pinMode (RELAY1, OUTPUT);
}
void loop(void)
{
digitalClockDisplay();
delay(1000);
Alarm.delay(1000);
}
void digitalClockDisplay(void)
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(' ');
Serial.print(day());
Serial.print(' ');
Serial.print(month());
Serial.print(' ');
Serial.print(year());
Serial.println();
lcd.setCursor(0,0);
lcd.print(hour(), DEC);
lcd.setCursor(2,0);
lcd.print(':');
lcd.setCursor(3,0);
lcd.print(minute(), DEC);
delay(1000);
void RelayOn(RELAY1, LOW) {
Serial.println("Alarm: - turn lights off");
}
}
void printDigits(int digits)
{
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(':');
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
Den Code habe ich versucht aus dem Beispiel der TimeAlarms Library abzuleiten:
/*
* TimeAlarmExample.pde
*
* This example calls alarm functions at 8:30 am and at 5:45 pm (17:45)
* and simulates turning lights on at night and off in the morning
* A weekly timer is set for Saturdays at 8:30:30
*
* A timer is called every 15 seconds
* Another timer is called once only after 10 seconds
*
* At startup the time is set to Jan 1 2011 8:29 am
*/
// Questions? Ask them here:d
// http://forum.arduino.cc/index.php?topic=66054.0
#include <TimeLib.h>
#include <TimeAlarms.h>
AlarmId id;
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor
setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011
// create the alarms, to trigger at specific times
Alarm.alarmRepeat(8,30,0, Relay); // 8:30am every day
Alarm.alarmRepeat(17,45,0,EveningAlarm); // 5:45pm every day
Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday
// create timers, to trigger relative to when they're created
Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds
id = Alarm.timerRepeat(2, Repeats2); // timer for every 2 seconds
Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds
}
void loop() {
digitalClockDisplay();
Alarm.delay(1000); // wait one second between clock display
}
// functions to be called when an alarm triggers:
void Relay() {
Serial.println("Alarm: - turn lights off");
}
void EveningAlarm() {
Serial.println("Alarm: - turn lights on");
}
void WeeklyAlarm() {
Serial.println("Alarm: - its Monday Morning");
}
void ExplicitAlarm() {
Serial.println("Alarm: - this triggers only at the given date and time");
}
void Repeats() {
Serial.println("15 second timer");
}
void Repeats2() {
Serial.println("2 second timer");
}
void OnceOnly() {
Serial.println("This timer only triggers once, stop the 2 second timer");
// use Alarm.free() to disable a timer and recycle its memory.
Alarm.free(id);
// optional, but safest to "forget" the ID after memory recycled
id = dtINVALID_ALARM_ID;
// you can also use Alarm.disable() to turn the timer off, but keep
// it in memory, to turn back on later with Alarm.enable().
}
void digitalClockDisplay() {
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits) {
Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}
Was übersehe ich und wie und wo genau schreibe ich den Befehl um das Relais zu aktivieren?