How do i freeze counter digits when pushbutton is pushed/pressed

Hi all i need help in this programming.This code allows me to run the program but only halfway through my objectives.I am using ULCD-43PT-AR touchscreen connected to Arduino UNO with a ribbon cable and the pushbuttons and LEDs are on a breadboard connected to the Arduino UNO with jumper wires.When i press the start button on the touchscreen,led digits start counting and LEDs on the breadboard light up together.Next,when a pushbutton is pressed it needs to off 1 LED and stop a counter at the same time.My code is already able to turn off individual LED.Right now what i need to do from here is that when i press a pushbutton,it needs to freeze & capture the value paused at the particular time i pressed the pushbutton. So now my problem is that when i press the push button using this code it doesnt freeze the counter and the led digit display(counter) keeps blinking and it’s unable to read ( doesnt pause/freeze at the time ).
Please help.Thanks a lot.

#include <genieArduino.h>

Genie genie;
int ledOutput1 =  11; 
int ledOutput2 =  12; // the number of the LED output pin
int ledState1 = 0; 
int ledState2 = 0; // variable for reading the LED status
int startBtn = 0;//varible for reading START winbutton on the screen 
int i=0;


void setup() {
  Serial.begin(9600);
  genie.Begin(Serial);
  genie.AttachEventHandler(myGenieEventHandler); 
  pinMode (ledOutput1, OUTPUT);
  pinMode (ledOutput2, OUTPUT) ;
  genie.WriteStr(0,  GENIE_VERSION);
  attachInterrupt(0,offLed1,CHANGE);
  attachInterrupt(1,offLed2,CHANGE); 
}

void loop() {
  genie.DoEvents();  
}

void myGenieEventHandler(){
  genieFrame Event;   
  char charbuf[50]; //to convert into char for showing state of winbutton in string0
  genie.DequeueEvent(&Event);
  
  if (genie.EventIs(&Event, GENIE_REPORT_EVENT, GENIE_OBJ_WINBUTTON, 0) || genie.EventIs(&Event, GENIE_REPORT_OBJ, GENIE_OBJ_WINBUTTON, 0))
  {                                                                                                                                      
    startBtn = genie.GetEventData(&Event);   //Receive the event data from the StartBtn
    sprintf(charbuf, "%d", startBtn);  //convert startBtn int value to char value to show in string0
    genie.WriteStr(0, charbuf);  //write char to string0 --> Strings0 will display the status of startBtn
  }
    if(startBtn == 1) // check the status of the START
    {   
        ledState1 = 1;
        ledState2 = 1;
    }
    digitalWrite(11, ledState1);   
    digitalWrite(12, ledState2);   
    timer();
    delay(10);
}

void offLed1() //pushbutton1
{
   ledState1 = 0;
   if (digitalRead(11) == HIGH)  
  digitalWrite(11,ledState1);
}

void offLed2() //pushbutton 2
{
  ledState2 = 0;
  if (digitalRead(12) == HIGH)
  digitalWrite(12,ledState2);
}

void timer() { //Start Timer
  genie.WriteStr(3, "Leddigits at\nvarious states"); //count from 0-99
  for(int i =0;i<10000;i++)
  {  
   genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00,i);
   genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01,i);
  
   if (ledState1 == 0 ) 
   genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00,LOW);
   else if (ledState2 == 0)
   genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01,LOW);
  } 
}
   

[\code]

I can’t help because I have no idea what your Genie library does. I only know simple stuff such as several things at a time.

…R

void timer() { //Start Timer

If the comment is accurate, that is a piss-poor name for the function. Functions are supposed to do something to/for/with something. They should, therefore have a verb and at least one noun in the name. digitalRead(), pinMode(), analogWrite(), for instance.

Yourpostishardtoreadwithoutspacesandparagraphs.

Next,when a pushbutton is pressed it needs to off 1 LED and stop a counter at the same time.

So, when some switch, connected to some undefined pin, is pressed, the Arduino should apply about 1000 volts to the LED to off it?

Try this again, explaining what you want to do/have happen using terms that make sense. One does not intentionally off an LED. One turns a pin off.

It's simple - you never check the button inside the timer loop.