Xbee - HELP - Receiving, not Transmitting

Problem:
I am able to send a signal and have it received, but when I want to send a signal back, it doesn't work.

Sender (defs & setup):

  #include <LCD4Bit.h>       //LCD library
  #undef int()               //For stdio
  #include <stdio.h>         //For sprintf
  
  #define debugPin 13        //Pin definitions
  #define pinSpeaker 37
  #define setSwitchPin 22
  #define alarmSwitchPin 26
  #define alarmEnabledPin 30
  #define incPin 32
  #define decPin 33
  #define setPin 38
  
  LCD4Bit lcd = LCD4Bit(2);  //2 line LCD
  
                             //Initial time set
  int sec=40;          
  int min=55;
  int hour=22;
  
  int amin=56;               //Initial alarm set
  int ahour=22;
  int alarmHit=0;
  int aDisable=0;
  
  char time[9];              //Time string for LCD
  
  int check=0;               //Button set value
  
                             //Set button variables
  int lastSetState = LOW; 
  int lastAlarmState = LOW; 
  int lastAlarmEnabledState = LOW;
  
  long lastDebounceTime = 0; 
  long debounceDelay = 50;  
  
  boolean alarmSet = false;  //Alarm on/off value, default off
  
  void setup() {                       //Initialization
    pinMode(debugPin, OUTPUT);         //Arduino debug LED
    pinMode(pinSpeaker, OUTPUT);       //Piezo buzzer
    pinMode(setSwitchPin, INPUT);      //Set button
    pinMode(alarmSwitchPin, INPUT);    //Alarm time button
    pinMode(alarmEnabledPin, INPUT);   //Alarm enabled switch
    pinMode(incPin, INPUT);            //Inc mom
    pinMode(decPin, INPUT);            //Dec mom
    pinMode(setPin, INPUT);            //Set mom
    
    Serial.begin(9600);      //COM Serial
    Serial1.begin(9600);     //Xbee Serial
    
    lcd.init();              //LCD prep
    lcd.clear();
  }

Sender (loop):

  void loop() {  
    unsigned long msbegin=millis();
    unsigned long msafter;
    digitalWrite(13, HIGH);                         //Light the debug LED
   
    lcd.cursorTo(1, 0);                             //Place cursor line 1 char 0
    lcd.printIn(inctime());                         //Print time
    digitalWrite(13, LOW);                          //Unlight the debug LED
   
    if (alarmSet == true) {                         //Only run if the alarm is on
      lcd.cursorTo(2, 0);                           //Place cursor line 2 char 0
      lcd.printIn("Wakeup at:");
      
      if (ahour == hour && amin == min) {           //Clock time = alarm time?
         alarmHit = 1;                              //Need to store the state of the alarm for after the 60s time interval
         Serial.println("Alarm!!!!!");              
      } else {
         alarmHit = 0;
         Serial.println("Alarm set off, but no more...");  
      }
    
      if (alarmHit == 1 && aDisable == 0) {         //Separate statemnent to allow for beyond 60s limit
                                                    //Send signal to xBee to start waiting for a button press
        Serial.println("Sending Xbee Start"); 
        Serial1.print(1, DEC);
        delay (10);

        lcd.cursorTo(2, 0);                         //Place cursor line 2 char 0
        lcd.printIn("WAKE UP!  ");
        
        int playFreq = 800;                         //Frequency of buzzer
        
        while (Serial1.read() == -1) {
            playTone(1000, playFreq); 
            delay (60);
            
            playFreq = playFreq - 100;
            
            if (playFreq == 300) {
              playFreq = 800;
            
            Serial.println("Still waiting to receive shutoff button");
            }
            
          //aDisable = Serial1.read();               //Once a button press is sent back, set aDisable to 1
           
          //Would add-in max count here for setting shower off
          
          }
         Serial.println("Shutoff signal received"); 
         aDisable = 1; 
       }
       
      lcd.cursorTo(2, 0);                           //Place cursor line 2 char 0
      lcd.printIn("Wakeup at:");                    //Set back to enable alarm for the next day
        
      lcd.cursorTo(2, 11);                          //Place cursor line 2 char 11
      sprintf(time, "%2d:%2d", ahour, amin);        //Print alarm setting time
      lcd.printIn(time);                            
    }
    
    //alarmSet = false;                               //Set alarm to disable
    
    msafter = millis();
    
      if (msafter < msbegin) {                      //Millis() reset after 9h due to overflow
       delay(1000);
      }
      else {
        delay(1000-(msafter-msbegin));
      }
      
      checkButtons();                               //Did you toggle the alarm set, time set, or alarm enabled?
      }

Receiver:

#define overridePin 5                //Pin definitions
#define shutoffPin 6
#define relayPin 7

int overReading;                     //Button readings
int lastoverReading;
int shutoffReading;
int lastshutoffReading;

int overCount=0;                     //Override count
int loopMe=0;                        //Remeber to loop

void setup() {                       //Initialization
  pinMode(overridePin, INPUT);
  pinMode(shutoffPin, INPUT);
  pinMode(relayPin, OUTPUT);
  
  Serial.begin(9600);                //Xbee Serial
}

void loop() {                        //Main loop
  overReading = digitalRead(overridePin);
  
                                     //Override pressed?
  if (overReading == 0) {  
    if (overCount==0) {              //Relay currently off
      digitalWrite(relayPin, HIGH);  //Set on
      overCount=1;                   //Store HIGH value
    } else {
      digitalWrite(relayPin, LOW);   //Set off
      overCount=0;                   //Store LOW value
    }
  }
  
  lastoverReading = overReading;     //Store previous button read
    
    if (Serial.read() != -1) {       
      digitalWrite(relayPin, HIGH);  //Turn on Shower
      loopMe = 1;
      
      if (loopMe == 1) {
                                     //Looking for the disabling of alarm
      shutoffReading = digitalRead(shutoffPin);
                                     //Check Press
      if (shutoffReading == 0) {  
        for (int i=0; i<1000; i++) {
          Serial.print(1, DEC);      //Send Xbee signal that the button was pressed                             
                                     //Store previous button read 
        }
          delay (10);
          loopMe = 0; 
      }
     }
    }
   }

You also need to tell us what type XBee you have (series 1 or 2/2.5) and what you've done to configure them.

if (Serial.read() != -1) {
      digitalWrite(relayPin, HIGH);  //Turn on Shower
      loopMe = 1;

      if (loopMe == 1) {
                                     //Looking for the disabling of alarm
      shutoffReading = digitalRead(shutoffPin);
                                     //Check Press
      if (shutoffReading == 0) {
        for (int i=0; i<1000; i++) {
          Serial.print(1, DEC);      //Send Xbee signal that the button was pressed
                                     //Store previous button read
        }
          delay (10);
          loopMe = 0;
      }
     }
    }

The sender only sends one character. You would have to be holding the shutoffPin switch down when that character was received, in order to send anything back.

That does not seem to be an ideal situation for an alarm clock. You need to be awake and holding the shutoff button when the alarm triggers, or you can never shut it up. I'd take that alarm back.

The condition you describe is what I want to avoid. I just fixed it. Now, the alarm clock doesn't resume after you hit the shut-up button. The LCD just stays on the time and wakeup at message. Looking for the logic error here...

Series 1.

Receiver:

void loop() {                        //Main loop
                                     //Override pressed?
  if (digitalRead(overridePin) == 0) {  
    if (overCount==0) {              //Relay currently off
      digitalWrite(relayPin, HIGH);  //Set on
      overCount=1;                   //Store HIGH value
    } else {
      digitalWrite(relayPin, LOW);   //Set off
      overCount=0;                   //Store LOW value
    }
  }
 
  Rval = Serial.read();
  
  if (Rval != -1) {       
      digitalWrite(relayPin, HIGH);  //Turn on Shower
      loopMe = 1;
  }
      
  if (loopMe == 1) {
      bVal = digitalRead(shutoffPin);
                                     //Looking for the disabling of alarm
                                     //Check Press
      if (bVal == 0) {  
        for (int i=0; i<20; i++) {
          Serial.print(1, DEC);      //Send Xbee signal that the button was pressed                             
                                     //Store previous button read 
        }
          loopMe = 0; 
      }
     }
}

Sender (loop):

  void loop() {  
    unsigned long msbegin=millis();
    unsigned long msafter;
    digitalWrite(13, HIGH);                         //Light the debug LED
   
    lcd.cursorTo(1, 0);                             //Place cursor line 1 char 0
    lcd.printIn(inctime());                         //Print time
    digitalWrite(13, LOW);                          //Unlight the debug LED
   
    if (alarmSet == true) {                         //Only run if the alarm is on
      lcd.cursorTo(2, 0);                           //Place cursor line 2 char 0
      lcd.printIn("Wakeup at:");
      
      if (ahour == hour && amin == min) {           //Clock time = alarm time?
         alarmHit = 1;                              //Need to store the state of the alarm for after the 60s time interval
         Serial.println("Alarm!!!!!");              
      } else {
         alarmHit = 0;
         Serial.println("Alarm set off, but no more...");  
      }
    
      if (alarmHit == 1 && aDisable == 0) {         //Separate statemnent to allow for beyond 60s limit
                                                    //Send signal to xBee to start waiting for a button press
        Serial.println("Sending Xbee Start"); 
        Serial1.print(1, DEC);
        delay (10);

        lcd.cursorTo(2, 0);                         //Place cursor line 2 char 0
        lcd.printIn("WAKE UP!  ");
        
        int playFreq = 800;                         //Frequency of buzzer
        
        Rval = Serial1.read();
        Serial.println(Rval);
        
        while (Rval == -1) {
            playTone(100, playFreq); 
            delay (5);
            
            playFreq = playFreq - 100;
            
            if (playFreq == 300) {
              playFreq = 800;
            
            Serial.println("Still waiting to receive shutoff button");
            }
            
          //aDisable = Serial1.read();               //Once a button press is sent back, set aDisable to 1
           
          //Would add-in max count here for setting shower off
          
          Rval = Serial1.read();
          }
         Serial.println("Shutoff signal received"); 
         aDisable = 1; 
       }
       
      lcd.cursorTo(2, 0);                           //Place cursor line 2 char 0
      lcd.printIn("Wakeup at:");                    //Set back to enable alarm for the next day
        
      lcd.cursorTo(2, 11);                          //Place cursor line 2 char 11
      sprintf(time, "%2d:%2d", ahour, amin);        //Print alarm setting time
      lcd.printIn(time);                       
 
      //alarmSet = false;     
    }
    
    //alarmSet = false;                               //Set alarm to disable
    
    msafter = millis();
    
      if (msafter < msbegin) {                      //Millis() reset after 9h due to overflow
       delay(1000);
      }
      else {
        delay(1000-(msafter-msbegin));
      }
      
      checkButtons();                               //Did you toggle the alarm set, time set, or alarm enabled?
      }

Now, the alarm clock doesn't resume after you hit the shut-up button. The LCD just stays on the time and wakeup at message.

Prior to the alarm time, the LCD should show the current time and alarm time. After the alarm time, but before the "All right, already! I'm up!!!" signal is received, what should it do? After the shut up signal is received, what should it do?

It isn't clear what the problem is.

[edit]On the sender, when is aDisable (supposed to be) reset? It has an initial value when the Arduino starts. That gets changed when the shut up signal is received. At some point, it needs to go back to it's original value, so the alarm can go off again the next day.[/edit]

Figured it out, with all my edits, I forgot to move the overflow above the alarmSet function. Fixed that issue.