servos and alarms for uno [solved]

Hi I'm trying to make an alarm that triggers a servo at a specified time to turn 180 degrees over the course of half an hour. I tested my alarm coding and my servo coding independently, and everything is going smoothly, but when I combine them, nothing happens. I hear a few weird noises from the servo every now and again, but I know they aren't the weird noises I'm looking for.

Here's my code:

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

Servo myServo;
int angle = 0;

void setup()
   {
   Serial.begin(9600);
   
   setTime(9,21,0,1,28,14);
   
   if( weekday() < 1 && weekday() > 7 )
      {
      Alarm.alarmRepeat( 9, 22, 0, wakeMeUp ); 
      } // end if
   
   myServo.attach( 9 );
   Serial.println( "Setting servo to 0" );
   myServo.write( angle );
   } // end setup
   
void wakeMeUp()
   {
   for( angle = 0; angle <= 180; angle++ )
      {
      myServo.write( angle );
      delay( 10000 );  
      if( angle == 180 )
         {
         myServo.write( angle );
         delay( 900000 );  
         } // end if
      } // end for
      
   for( angle = 180; angle >= 0; angle-- )
      {
      myServo.write( angle );
      delay( 10 );  
      } // end for
   } // end Alarm
   
void loop()
   {
     
   } // end loop

Any suggestions would be greatly appreciated.

Hi,

Could you copy and paste the codes you used when you tested them separately?

Jasper

   setTime(9,21,0,1,28,14);

What does this set the date and time to bearing in mind the definition of setTime as

setTime(hr,min,sec,day,month,yr)

  if( weekday() < 1 && weekday() > 7 )

Will the day of the week ever be less than 1 and greater than 7 ?

    if( angle == 180 )
    {
      myServo.write( angle );
      delay( 900000 );  
    } // end if

Why have this in the for loop and not after it ? There is no need to test the value of angle after the for loop because the servo will have moved all the way anyway.

Thank you both for your responses, they were quick and helpful. I fixed the problems by following UKHeliBob's suggestions, the most important fixes being switching the inequality signs for the weekday if statement and switching the day and month numbers in the setAlarm() method. I looked back at the old program that I tested the Alarm independently on for Jasper and it turns out that I had gotten the day place and the month place confused because the alarm was set for January 1, so the two numbers were interchangeable on that one.

Why check the day of the week at all unless you are going to do different things on different days, and even if you are, you can set that directly using the alarmRepeat method

I notice that you are not calling Alarm.delay() anywhere in your program so the alarm will not work anyway.