trying to make it so that when the time from DS3231 is equal to the set alarm time, the buzzer of the alarm will go off. however, i get an error saying that i cannot compare the 2. error is second last line. do i need to rewrite the code?
#include <DS3231.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <LiquidCrystal.h>
#include <Wire.h>
#include <stdlib.h>
DS3231 rtc (SDA, SCL);
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
int buzzerPin = 10;
int rc = 9;
IRrecv irrecv(rc);
decode_results results;
long num[10] = {0xFF6897, 0xFF30CF, 0xFF18E7, 0xFF7A85, 0xFF10EF, 0xFF38C7, 0xFF5AA5, 0xFF42BD, 0xFF4AB5, 0xFF52AD};
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int setAlarm = 0;
void setup() {
lcd.begin(16, 2);
rtc.begin();
irrecv.enableIRIn();
}
void loop() {
lcd.setCursor(0,0);
lcd.print("Time: ");
lcd.print(rtc.getTimeStr());
lcd.setCursor(0,0);
getAlarm();
}
void getAlarm(){
if (irrecv.decode(&results)){
Serial.println(results.value, HEX);
irrecv.resume();
if(results.value==0xFFB04F){
setAlarm=1;
}else if(results.value==0xFFFFFFFF){
setAlarm = setAlarm;
}
}
if(digitalRead(buzzerPin)==HIGH){
setAlarm=5;
}
while(setAlarm==1){
lcd.setCursor(0,0);
lcd.print("Set Hour");
lcd.setCursor(0,1);
if(irrecv.decode(&results)){
for(int i = 0; i<10; i++){
if(results.value==num[i]){
a = a*10+i;
}else if(results.value==0xFFFFFFFF){
a = a;
}
irrecv.resume();
}
if(a<24){
lcd.print(a);
if(results.value==0xFFB04F){
setAlarm=2;
}
}else{
lcd.clear();
setAlarm = 1;
a=0;
}
}
}
while(setAlarm==2){
lcd.setCursor(0,0);
lcd.print("Set Minute");
lcd.setCursor(0,1);
if(irrecv.decode(&results)){
for(int i = 0; i<10; i++){
if(results.value==num[i]){
b = b*10+i;
}else if(results.value==0xFFFFFFFF){
b = b;
}else if(results.value==0xFFB04F){
setAlarm++;
}
irrecv.resume();
}
lcd.print(a);
lcd.print(':');
if(b<60){
lcd.print(b);
if(results.value==0xFFB04F){
setAlarm=3;
}
}else{
lcd.clear();
setAlarm = 2;
b=0;
}
}
}
while(setAlarm==3){
lcd.setCursor(0,0);
lcd.print("Set Second");
lcd.setCursor(0,1);
if(irrecv.decode(&results)){
for(int i = 0; i<10; i++){
if(results.value==num[i]){
c = c*10+i;
}else if(results.value==0xFFFFFFFF){
c = c;
}else if(results.value==0xFFB04F){
setAlarm++;
}
irrecv.resume();
}
lcd.print(a);
lcd.print(':');
lcd.print(b);
lcd.print(':');
if(c<60){
lcd.print(c);
if(results.value==0xFFB04F){
setAlarm=4;
}
}else{
lcd.clear();
setAlarm = 3;
c=0;
}
}
}
while(setAlarm==4){
lcd.setCursor(0,1);
lcd.print("Alarm: ");
if(a<10)lcd.print("0");
lcd.print(a);
lcd.print(':');
if(b<10)lcd.print("0");
lcd.print(b);
lcd.print(':');
if(c<10)lcd.print("0");
lcd.print(c);
if(results.value==0xFFB04F){
setAlarm=0;
}
}
if(rtc.getTime() == getAlarm){
tone(buzzerPin, 100);
a=0;
b=0;
c=0;
}
if(irrecv.decode(&results)){
if(results.value==0xFFA25D){
a=0;
b=0;
c=0;
lcd.setCursor(0,1);
lcd.clear();
}
}
}