Czy ten kod jest poprawny? Rtc podłączone poprawnie, wyświetla godzinę, biblioteki zainstalowane, a pin 13 ani drgnie o wyznaczonym czasie. Gdzieś coś jest pokręcone ?
#include #include #include #include // a basic DS1307 library that returns time as a time_t
Serial.begin(9600); // wait for Arduino Serial Monitor while (!Serial) ;
// get and set the time from the RTC setSyncProvider(RTC.get); if (timeStatus() != timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time");
// to test your project, you can set the time manually //setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011
// create the alarms, to trigger functions at specific times Alarm.alarmRepeat(9,0,0,MorningAlarm); // 9:00am every day Alarm.alarmRepeat(11,26,0,EveningAlarm); // 19:00 -> 7:00pm every day }
void loop() { digitalClockDisplay(); // wait one second between each clock display in serial monitor Alarm.delay(1000); }
// functions to be called when an alarm triggers void MorningAlarm() { // write here the task to perform every morning Serial.println("Tturn light off"); digitalWrite(led, LOW); } void EveningAlarm() { // write here the task to perform every evening Serial.println("Turn light on"); digitalWrite(led, HIGH); }
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); } #arduino #programowanie
@5MinutWolnosci: Zobacz jakich pinów używają biblioteki, może się zdarzyć tak że się nakładają. A druga sprawa, nie wiadomo czy sa wyzwalane zdarzenia. Wrzuć w pętle miganie diodką to będziesz wiedział.
@5MinutWolnosci: No to proste, biblioteka nie działa tak jak potrzeba. Zobacz czy nie trzeba czegoś z biblioteki Alarm procesować w pętli. Edit: prawdopobnie brakuje w pętli Alarm.delay(1000);
#include
#include
#include
#include // a basic DS1307 library that returns time as a time_t
const int led = 13;
void setup() {
// prepare pin as output
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
Serial.begin(9600);
// wait for Arduino Serial Monitor
while (!Serial) ;
// get and set the time from the RTC
setSyncProvider(RTC.get);
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
// to test your project, you can set the time manually
//setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011
// create the alarms, to trigger functions at specific times
Alarm.alarmRepeat(9,0,0,MorningAlarm); // 9:00am every day
Alarm.alarmRepeat(11,26,0,EveningAlarm); // 19:00 -> 7:00pm every day
}
void loop() {
digitalClockDisplay();
// wait one second between each clock display in serial monitor
Alarm.delay(1000);
}
// functions to be called when an alarm triggers
void MorningAlarm() {
// write here the task to perform every morning
Serial.println("Tturn light off");
digitalWrite(led, LOW);
}
void EveningAlarm() {
// write here the task to perform every evening
Serial.println("Turn light on");
digitalWrite(led, HIGH);
}
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);
}
#arduino #programowanie
@NoMoreTearsJustSmile: jest to na swój sposób urocze #include ʕ•ᴥ•ʔ
Edit: prawdopobnie brakuje w pętli Alarm.delay(1000);
void loop() {
digitalClockDisplay();
// wait one second between each clock display in serial monitor
Alarm.delay(1000);
}
Jest w kodzie