i added
if (!blinking){
digitalWrite(ledPin, LOW);}
now it works
so i went back to the blinking if the button is pressed and i ended up with this code
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int currState;
int prevState = LOW;
bool blinking = false;
void setup() {
pinMode(ledPin, OUTPUT); // initialize the LED pin as an output
pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input
}
void loop(){
currState = digitalRead(buttonPin); //check the current state of the button pin
if (currState != prevState){ //the button has been pressed
if(currState == HIGH){
blinking = !blinking;
}
}
prevState = currState;
if (blinking){
digitalWrite (ledPin, HIGH);
delay(500);
digitalWrite (ledPin, LOW);
delay(500);
}
if (!blinking){
digitalWrite(ledPin, LOW);
}
}
this does the job how ever, i must hold the button for maybe 1 second before it will turn off, i expect this is due to the delay's im using on the blink.
time to learn blink with out delays.
thank you very much for the assistance tonight. most appreciated.
ash.