motor alarm

Hi All, I'm very new to arduino programming I''m trying to make the alarm high when the brake is high i.e both functions execute at the same time, pls can you help

/************************************************************* Motor Shield 1-Channel DC Motor Demo by Randy Sarafan

For more information see: http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/

*************************************************************/ int LxAlarm = 6; int Brake = 9; int Direction = 12; int Speed = 3;

void setup() {

//Setup Channel A pinMode(12, OUTPUT); //Initiates Motor Direction on Channel A pin pinMode(9, OUTPUT); //Initiates Brake on Channel A pinMode(3, OUTPUT); //Initiates Speed (PWN) on Channel A pinMode(A0, OUTPUT); //Sense current

//Setup for level crossing alarm pinMode(6, OUTPUT); //Initiates alarm at PIN 7

}

void loop(){ // if (Brake == HIGH) // { // analogWrite (LxAlarm, 255); // }

//forward @ full speed digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A analogWrite(3, 180); //Spins the motor on Channel A at full speed delay(4000);

digitalWrite(9, HIGH); //Engage the Brake for Channel A delay(4000); analogWrite(LxAlarm, 255); delay(4000);

digitalWrite(12, HIGH); //Establishes forward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A analogWrite(3, 180); //Spins the motor on Channel A at full speed delay(4000);

digitalWrite(9, HIGH); //Engage the Brake for Channel A delay(4000);

//backward @ half speed digitalWrite(12, LOW); //Establishes backward direction of Channel A digitalWrite(9, LOW); //Disengage the Brake for Channel A analogWrite(3, 100); //Spins the motor on Channel A at half speed delay(4000);

digitalWrite(9, HIGH); //Engage the Brake for Channel A delay(4000);

}

I’'m trying to make the alarm high when the brake is high
i.e both functions execute at the same time, pls can you help

It isn’t clear to me what it is you want to do.
You’re driving the brake, so you know when it is HIGH.

Please remember to use code tags when posting code.

Don't use delay() in your sketches.

You freeze your sketch for that period of time.

Use the BWD BlinkWithoutDelay technique, an example is in the IDE.

Read Robin2's discussion: http://forum.arduino.cc/index.php?topic=223286.0 .