Alarm clock problem

Hi guys i am currently trying to write a code for alarm clock, but i am having some problem writing the alarm setting part.

i am using two 12 position rotary switch and one latching switch for the alarm setting

one rotary switch would be for hour 1=1oclock, 2=2oclock
one rotary switch for minute 1=5 mins, 2=10 mins, 3=15mins
latching switch pressed = on alarm, not pressed = turn off alarm

i am having problem putting variables from switch into the alarm setting part
im thinking maybe im using the wrong function?
im not sure is this the right approach, i am sorry i am quite a newbie in this, this might be wrong because i took different parts from different examples online

#include <Time.h>
#include <TimeAlarms.h>

int led1 = 13;
const int firsthourrotaryPin = 1;
const int lasthourrotaryPin = 12;

void setup()
{
 pinMode(led1, OUTPUT); // alarm light
 //set up rotary switch
 for(int hourtime=firsthourrotaryPin; hourtime<= lasthourrotaryPin; hourtime++) {
 pinMode(hourtime, INPUT); 
 digitalWrite(hourtime, HIGH); // turn on internal pullup resistor
 
 }

 setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011
}
 // create the hour rotary switch
   int getRotaryValue() {
     for( int hourtime=firsthourrotaryPin; hourtime<= lasthourrotaryPin; hourtime++) {
       int hourhands = digitalRead ( hourtime ) ; //look at a hour rotary switch input
     }
   }


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Alarm.alarmRepeat(hourhands,30,0, MorningAlarm);  //setting the alarm ( think this is the problem)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

void loop(){
 
 Alarm.delay(1000); // wait one second between clock display
}

 
void MorningAlarm() {
 digitalWrite(led1, HIGH); 
 delay(8000); //wait for a second
 digitalWrite(led1, LOW);  //TURN Off LED1
}

thank youuuu

Half your code is smilies. Try posting it in code tags.

better? sorry, first post, i just wanted to use that to show where i think the problem is

Welcome to the forum.

Where do you call getRotaryValue?
Are you aware pin 1 is used as the TX pin?
Always show us a schematic of your circuit.
Always put you code between code tags, use the code icon.

2014-11-19_21-59-49.jpg

 int getRotaryValue() {
      for( int hourtime=firsthourrotaryPin; hourtime<= lasthourrotaryPin; hourtime++) {
        int hourhands = digitalRead ( hourtime ) ; //look at a hour rotary switch input
      }
    }

hourhands is created inside the for loop so it is local to the for loop. Every time the for loop rolls over that variable is destroyed. It doesn’t exist outside the for loop.

Create that variable at global scope and I think it will do what you want.

So meaning this?

    int getRotaryValue() {
      for( int hourtime=firsthourrotaryPin; hourtime<= lasthourrotaryPin; hourtime++) {
        int hourhands = digitalRead ( hourtime ) ; //look at a hour rotary switch input
       
      }
    }
 
Alarm.alarmRepeat(getRotaryValue(),30,0, MorningAlarm);  //setting the alarm

as getRotary Value is out of the {} so its a global variable?

the error i got from the code was

error: expected constructor, destructor, or type conversion before ‘.’ token

highlighted
Alarm.alarmRepeat(getRotaryValue(),30,0, MorningAlarm); //setting the alarm
[/code]