my code:
#include <Time.h>
#include <TimeAlarms.h>
#include <IRremote.h>
int RECV_PIN = 9;
const int RELAY_0 = A0;
const int RELAY_1 = A1;
const int RELAY_2 = A2;
const int RELAY_3 = A3;
const int RELAY_4 = A4;
const int RELAY_5 = A5;
int sethour;
int setmin;
int setsec = 00;
int setday;
int setmonth;
int setyear = 11;
int count;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define one 0x801
#define two 0x802
#define three 0x803
#define four 0x804
#define five 0x805
#define six 0x806
#define seven 0x807
#define eight 0x808
#define nine 0x809
#define zero 0x800
void setup()
{
pinMode(RELAY_0, OUTPUT);
pinMode(RELAY_1, OUTPUT);
pinMode(RELAY_2, OUTPUT);
pinMode(RELAY_3, OUTPUT);
pinMode(RELAY_4, OUTPUT);
pinMode(RELAY_5, OUTPUT);
pinMode(13, OUTPUT);
irrecv.enableIRIn(); // start the receiver
Serial.begin(9600);
}
int on = 0;
unsigned long last = millis();
boolean cycle = true; //auto-cylce mode
/*
void MorningAlarm()
{
Serial.println(“Alarm: - turn lights off”);
}
void EveningAlarm()
{
Serial.println(“Alarm: - turn lights on”);
}
void RepeatTask()
{
Serial.println(“15 second timer”);
}
void OnceOnlyTask()
{
Serial.println(“This timer only triggers once”);
}
*/
void loop() {
int buttonValue = digitalRead(RECV_PIN);
while (irrecv.decode (&results)){
Serial.println(“Input the hour using the remote. (Military time 0-24) \n For example: Three am would be 0 followed by 3, 1 pm would be 1 followed by 3”);
Serial.println("\n");
if (results.value == zero){
sethour = 0;
cycle = false;
}
else if (results.value == one){
sethour = 1;
cycle = false;
}
else if (results.value == two){
sethour = 2;
cycle = false;
}
else if (results.value == three){
sethour = 3;
cycle = false;
}
else if (results.value == four){
sethour = 4;
cycle = false;
}
else if (results.value == five){
sethour = 5;
cycle = false;
}
else if (results.value == six){
sethour = 6;
cycle = false;
}
irrecv.resume();
Serial.println(“Input the minute. \n For example 8 would be 0 followed by 8, 23 would be 2 followed by 3”);
Serial.println("\n");
if (results.value == zero){
setmin = 0;
cycle = false;
}
else if (results.value == one){
setmin = 1;
cycle = false;
}
else if (results.value == two){
setmin = 2;
cycle = false;
}
else if (results.value == three){
setmin = 3;
cycle = false;
}
else if (results.value == four){
setmin = 4;
cycle = false;
}
else if (results.value == five){
setmin = 5;
cycle = false;
}
else if (results.value == six){
setmin = 6;
cycle = false;
}
irrecv.resume();
Serial.println(“Input the day using the same method as above.”);
Serial.println("\n");
if (results.value == zero){
setday = 0;
cycle = false;
}
else if (results.value == one){
setday = 1;
cycle = false;
}
else if (results.value == two){
setday = 2;
cycle = false;
}
else if (results.value == three){
setday = 3;
}
else if (results.value == four){
setday = 4;
}
else if (results.value == five){
setday = 5;
}
else if (results.value == six){
setday = 6;
}
irrecv.resume();
Serial.println(“Input the month using the same method as above.”);
Serial.println("\n");
if (results.value == zero){
setmonth = 0;
}
else if (results.value == one){
setmonth = 1;
}
else if (results.value == two){
setmonth = 2;
}
else if (results.value == three){
setmonth = 3;
}
else if (results.value == four){
setmonth = 4;
}
else if (results.value == five){
setmonth = 5;
}
else if (results.value == six){
setmonth = 6;
}
irrecv.resume();
}
//setTime(sethour,setmin,setsec,setday,setmonth,setyear); // set time
/*
Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day
Alarm.alarmRepeat(17,45,0,EveningAlarm); // 5:45pm every day
Alarm.timerRepeat(15, RepeatTask); // timer for every 15 seconds
Alarm.timerOnce(10, OnceOnlyTask); // called once after 10 seconds
*/
digitalClockDisplay();
Alarm.delay(1000); // wait one second between clock display
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
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);
}
on the serial monitor, everything repeats itself, when i push a button on the remote, the value is passed into the setTime function but does not start counting up.
i tried setting some logic flags but nothing worked. :0
what is the problem with my code?