Not sure how to do this, Need some help.

I feel like this should be simple however I can't figure out how to make it work. This is my first attempt and I thought it would be a good starter project. But it has me stumped...

I have a button on pin 10, when that is pressed once, I would like to flash an LED on pin 11 indefinitely. Then I would like to have another button on pin 12 that when pressed once stops the LED on pin 11 from flashing. If the button on pin 10 is pressed again, I would like the LED to flash again ect...

This is what I have for code so far, My pulldowns for the buttons are being done with resistors in an effort to keep the code simple.

const int gpo = 10; //start button
const int led = 11; //led
const int ackbutt = 12; //acknowledge button

int gpoState = 0;
int flag=0;

void setup() {
pinMode(gpo, INPUT);
pinMode(led, OUTPUT);
pinMode(ackbutt, INPUT);
}

void loop() {
  gpoState = digitalRead(gpo);
  if (gpoState == HIGH) {
    if ( flag ==0){
  digitalWrite(led, HIGH);
  delay(700);
  digitalWrite(led, LOW);
  delay(700);
  digitalWrite(led, HIGH);
  delay(700);
  digitalWrite(led, LOW);
  delay(700);
  digitalWrite(led, HIGH);
  delay(700);
  digitalWrite(led, LOW);
  delay(2000);
  flag=1;
  }
  }
}

Read this - https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay

Don't use delay() to manage timing because the Arduino can do nothing during a delay(). Use millis() as illustrated in several things at a time

This pseudo code should do what you want

void loop() {
  if onButton is pressed
     blinkOn = true;

  if offButton is pressed
     blinkOn = false;

  blinkLed();
 )

 void blinkLed() {
    if blinkOn == true
      make LED blink

    else
       turn LED off
 }

...R

stinkyone:
I have a button on pin 10, when that is pressed once, I would like to flash an LED on pin 11 indefinitely.
Then I would like to have another button on pin 12 that when pressed once stops the LED on pin 11 from flashing. If the button on pin 10 is pressed again, I would like the LED to flash again ect…

This is what I have for code so far, My pulldowns for the buttons are being done with resistors in an effort to keep the code simple.

Perhaps you’d like to give it a try (untested code):

const byte GPOPIN = 10; //start button
const byte ACKPIN = 12; //acknowledge button

// define a suitable data structure for a blinking pin
struct blinker_t {byte pin; uint16_t onTime; uint16_t cycleDuration; uint32_t cycleStartTime;};

blinker_t myBlinker={11,0,2700}; // pin-11, 0 ms ON time initially, 2700 ms repeat period

void myBlinkerUpdate()
{
  unsigned long now=millis();
  if (now-myBlinker.cycleStartTime >= myBlinker.cycleDuration)  myBlinker.cycleStartTime+=myBlinker.cycleDuration;
  boolean isOn= (now-myBlinker.cycleStartTime < myBlinker.onTime); 
  digitalWrite(myBlinker.pin, isOn);
}


void setup() {
  pinMode(myBlinker.pin, OUTPUT);
}

void loop() {
  if (digitalRead(GPOPIN)) myBlinker.onTime=700;
  if (digitalRead(ACKPIN)) myBlinker.onTime=0;  
  myBlinkerUpdate();
}

The ACKPIN is handled after the GPOPIN in the loop() function, so in case both buttons should be pressed at the same time, the blinker will always stay in OFF state.

BTW: Would it be very complicated to use a MEANINGFUL SUBJECT LINE in your posting?

    if ( flag ==0){

At this point, we are supposed to guess what flag holds, and what it means.

How about this statement? Can you guess what this variable holds and what it means?

if(shouldBeBlinking == true) // The == true part is for Robin2

Meaningful names mean that the next time you look at the code you don't need to scratch your head wondering "what was I thinking? Or was I?".

Thanks for your feedback everyone. I will attempt this again based on your reply's. I appreciate the help.

Sorry for the lack of notes and the non meaningful subject line. I was very frustrated when I posted this last night and I will do a better job of including notes in my sketches.