Code help needed

Hi, I am building an "emergency party button" and would appreciate some help with the code. Here's the setup:

X10 Cm17a wireless module wired up to Arduino for control.

Keyswitch (keyPin) ON turns on led cyclon and powers a simple 9v alarm circuit and simple 9v LM386 amp circuit. Led cyclon circuit is 3v and runs off Arduino power. The external amp and alarm circuits are powered by 9v batteries and connected to digital pins and Tip120 transistors for switching.

If Keyswitch is HIGH, Red guarded switch (switchPin) ON kills the amp and alarm, leaves the led's on, and allows X10 commands to start party mode.

When the switchPin is turned off, everything returns to normal.

The X10 control and the led cyclon circuit work as predicted, but I can't get the alarm and amp to run. I don't have a picture of the circuit but the both the amp and the alarm are wired up according to this diagram:

My code is below. I figure my problem is somewhere in there. Thanks for your help!

/* Arduino Interface to the CM17A Wireless X10 dongle. BroHogan 7/19/08
 * Arduino Library Conversion by DaveK AC0KG  Dec/08
 *Party Button by Spikec Apr/11
 * The CM17A gets it power and data using only the RTS, CTS, & Gnd lines.
 * CONNECTION: RTS -> DB9 pin 7.  DTR -> DB9 pin 4. Gnd. -> DB9 pin 5.
 * See X10Firecracker.cpp in your libraries folder for more details
 */

int keyPin = 10;
int switchPin = 6;
int alarmPin = 7;
int ampPin = 9;
int ledPin = 12;

#include <X10Firecracker.h>

#define RTS_PIN     2	                // RTS line for C17A - DB9 pin 7
#define DTR_PIN     3	                // DTR line for C17A - DB9 pin 4
#define BIT_DELAY   1                   // mS delay between bits (1 mS OK)


void setup()
{
  X10.init(RTS_PIN, DTR_PIN, BIT_DELAY);    //init X10 
  pinMode(keyPin, INPUT);                  //Set keyswitch as input
  pinMode(switchPin, INPUT);              //Set red switch as input
  pinMode(ledPin, OUTPUT);               //Set led circuit as output
  pinMode(alarmPin, OUTPUT);            //Set alarm circuit as output 
  pinMode(ampPin, OUTPUT);             //set amp as output
}

void PartyOn()                         //turn off overhead can lights and start up party lights
{
  X10.sendCmd( hcA, 1, cmdOff );             //overhead can lights
  X10.sendCmd( hcA, 2, cmdOff );             //overhead bar lights
  X10.sendCmd( hcA, 7, cmdOn );             //led strip under bar
  X10.sendCmd( hcA, 8, cmdOn );             //led strip under railing
  X10.sendCmd( hcA, 3, cmdOn );             //fog machine
  X10.sendCmd( hcA, 4, cmdOn );             //laser scanner
  X10.sendCmd( hcA, 5, cmdOn );             //mushroom spot
  X10.sendCmd( hcA, 6, cmdOn );             //strobe light

}

void PartyOff()                       //return everything to normal
{
  X10.sendCmd( hcA, 3, cmdOff );
  X10.sendCmd( hcA, 4, cmdOff );
  X10.sendCmd( hcA, 5, cmdOff );
  X10.sendCmd( hcA, 6, cmdOff );
  X10.sendCmd( hcA, 1, cmdOn );
  X10.sendCmd( hcA, 2, cmdOn );
  X10.sendCmd( hcA, 7, cmdOff );
  X10.sendCmd( hcA, 8, cmdOff );

}

void loop()
 {
    if (digitalRead(keyPin) == HIGH) //Start led's and alarm on control box when keyswitch turned on

    {

    digitalWrite(ledPin, HIGH);
    digitalWrite(ampPin, HIGH);
    digitalWrite(alarmPin, HIGH);
     
    }

    else

    {
      digitalWrite(ledPin, LOW);     //Turn off led's and alarm if keyswitch off
      digitalWrite(alarmPin, LOW);
      digitalWrite(ampPin, LOW);
        }

   {

      if (digitalRead(switchPin) == HIGH && (digitalRead(keyPin) == HIGH))
      
        {
        digitalWrite(ampPin, LOW); //Turn off alarm when party mode (red switch) activated
        digitalWrite(alarmPin, LOW);
        PartyOn();   //Call PartyOn function, start party mode
         }
        
      
else

      PartyOff();  //Stop party mode and return things to normal
          }
        }

What 9V batteries are you using?

Just regular old 9v alkalines, which is what the amp and alarm circuits were designed for...do you think I need more juice going to them?

Ok, I'm 90% there. I replaced one of the Tip120's and now when the keySwitch is HIGH, it turns the alarm and led's on just fine. But when the 2nd switch (switchPin) is HIGH, the alarm should go off while the led's remain on. My first "if" statement is conditional on the state of keySwitch:

void loop()
 {
    if (digitalRead(keyPin) == HIGH) //Start led's and alarm on control box when keyswitch turned on

    {

    digitalWrite(ledPin, HIGH);
    digitalWrite(ampPin, HIGH);
    digitalWrite(alarmPin, HIGH);
     
    }

I think the second "if" statement (which tells it to look at both switches and if both are on, shut down the alarm) is where my problem is.

if (digitalRead(switchPin) == HIGH && (digitalRead(keyPin) == HIGH))
      
    {
        digitalWrite(ampPin, LOW); //Turn off alarm when party mode (red switch) activated
        digitalWrite(alarmPin, LOW);

}

This should be pretty simple but I'm pretty green at programming. Any ideas?

Thanks!

Sorry you haven't told me what batteries - PP3, PP6, PP9 or what?

The batteries aren't germaine to the problem anymore. I've got both external circuits working with both off the shelf 9v eveready's and with my lab power supply. What I can't figure out is how to get the alarm to shut off when the second switch is closed - a code problem from what I can tell...