Thanks, I think that's a great starting point and will certainly help me in future.
I've actually found this code to work - when I hold the button down it ensures the led flashes.
So I'm as good as done, I'll just butched the code to make it do what I want.
#include <stdio.h>
#include <stdlib.h>
const int button = 15; // GPIO 15 for the button
const int led =12; // GPIO 12 for the LED
int ledflag=0; // LED status flag
void setup() {
pinMode(button,INPUT); // define button as an input
pinMode(led,OUTPUT); // define LED as an output
digitalWrite(led,HIGH); // turn output off just in case
}
void loop() {
if (digitalRead(button)==LOW){ // if button is pressed
if (ledflag==0) { // and the status flag is LOW
ledflag=1; // make status flag HIGH
digitalWrite(led,LOW); // and turn on the LED
} //
else { // otherwise...
ledflag=0; // make status flag LOW
digitalWrite(led,HIGH); // and turn off the LED
}
delay(1000); // wait a sec for the
} // hardware to stabilize
} // begin again