hi there i need help with arduino i need some way to delay until buttonpin == high
this is my code im using now
const int buttonPin = 2; // the number of the pushbutton pin
const int one = 6; // the number of the LED pin
const int call = 5; // the number of the LED pin
const int endCall = 4; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int waitTime =4000; // delay bettween call and end call
void setup() {
// initialize the LED pin as an output:
pinMode(one, OUTPUT);
pinMode(call, OUTPUT);
pinMode(endCall, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
digitalWrite(one, HIGH);
digitalWrite(call, HIGH);
digitalWrite(endCall, HIGH);
delay(3000);
}
void loop(){
// read the state of the pushbutton value:
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (digitalRead(buttonPin) == LOW)
{
digitalWrite(one, LOW);
delay(500);
digitalWrite(one, HIGH);
delay(300);
digitalWrite(call, LOW);
delay(500);
digitalWrite(call, HIGH);
delay(waitTime);
digitalWrite(endCall, LOW);
delay(500);
digitalWrite(endCall, HIGH);
// the problem
delay(digitalRead(buttonPin) == HIGH);
}
}