i tried to upgrade the codes and apply it in my project.However, an error appeared.sorry i am new to arduino.i attached along the image of my problem.
Post your code.
Use code tags.
Do not post an image of your code.
I'd be worried about the "a function declaration is not allowed" error message.
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
#include <LiquidCrystal.h>
#include <SD.h> // SD card Library
#include <SPI.h>
LiquidCrystal lcd(41, 39, 37, 35, 33, 31); // LCD Pin
int irpin=32; // IR sensor Pin
char timedatebuf[65]; // Time and Date string buffer
int year4digit; // 4 digit year
int buzzer=22;// initialize buzzer pin
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day
Alarm.alarmRepeat(17,45,0, EveningAlarm);
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");
Serial.print("Initializing SD card...");
pinMode(53, OUTPUT);
if (!SD.begin(53)) { // check if card is installed
Serial.println("No SD Card present in module");
return;
}
Serial.println("SD Card Ready");
pinMode (irpin, INPUT);
pinMode (buzzer, OUTPUT);
// create the alarms
Alarm.alarmRepeat(10,10,0, MorningAlarm); // 8:30am every day
Alarm.alarmRepeat(17,45,0,EveningAlarm);
}
void loop()
{
tmElements_t tm;
void MorningAlarm(){
digitalWrite (buzzer, HIGH);
delay(5000);
digitalWrite (buzzer, HIGH);
}
void loop()
{
tmElements_t tm;
void MorningAlarm(){
Yup, there it is - don't try to declare a function inside another function.
okok.i saw the problem dy.thx thx
the buzzer dint produce sound when the time reach? anyone can help?
Post your code.
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
#include <LiquidCrystal.h>
#include <SD.h> // SD card Library
#include <SPI.h>
LiquidCrystal lcd(41, 39, 37, 35, 33, 31); // LCD Pin
int irpin=32; // IR sensor Pin
char timedatebuf[65]; // Time and Date string buffer
int year4digit; // 4 digit year
int buzzer=22;// initialize buzzer pin
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
//create the alarms
pinMode(buzzer, OUTPUT);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Alarm.alarmRepeat(0,58,0,MorningAlarm); // 8:30am every day
Serial.println("RTC has set the system time");
}
void loop() {}
void MorningAlarm(){
digitalWrite (buzzer, HIGH);
delay(5000);
digitalWrite (buzzer, LOW);
}
Duplicate thread - Buzzer can't produce sound when the time is set - Programming Questions - Arduino Forum
Other thread locked.
DO NOT CROSS-POST, CROSS-POSTING WASTES TIME.
