Problem with buttons function. (IF)???

Hi all i have a question for you.

The code i have in this topic works, it have two buttons to flash one led , with a delay of 150 on off .

I wont it to work like this:

The flashing of the led should go high/on when the buttonPin 11 is pressed , but its only allowed to work if the other buttonPin2 is high, when buttonPin 2 is low nothing should happend.

Can you help me with that?

Best Regards

Patrik

" // constants won't change. They're used here to // set pin numbers: const int buttonPin = 11; // the number of the pushbutton pin const int ledPin = 8; const int buttonPin2 = 7; // the number of the LED pin

// variables will change: int buttonState = 0; int buttonState1 = 0; // variable for reading the pushbutton status

void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); pinMode(buttonPin2, INPUT); }

void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); buttonState1 = digitalRead(buttonPin2);

// check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); delay(150); digitalWrite(ledPin, LOW); delay(150); } if (buttonState1 == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); delay(150); digitalWrite(ledPin, LOW); delay(150); } else { // turn LED off: digitalWrite(ledPin, LOW); } }"

Instead of:

  if (buttonState == HIGH) {

use

  if (buttonState == HIGH && buttonState1==HIGH) {

Thanks alot!!!