I want to create a time count with an external interrupt

I have 223B-SNFI touch pad sensor modules (x2) and 4-digit 7 segment module with TM1637 driver.
I want when both touch pad modules touched, the timer starts with " 0:00.0 " (minutes:seconds.tenth of second) format and display the time on 4-digit 7 segment module and count up until touch pads touched again.
I connected the out pin of touch pad modules to 4.7k ohm resistors as parallel and connected that connection point to the digital pin 2 of arduino like this:

[TP1] --- [R1(4.7kohm)] ---
|____ [R3(4.7kohm)]____ [digital pin2 of arduino]
|
[TP2] --- [R2(4.7kohm)] ---
I defined the pin2 as interrupt pin with:

#define interruptPin  2

and defined the interrupt with this:

attachInterrupt(digitalPinToInterrupt(interruptPin), ST, HIGH);

But cannot run and start or stop the timer.
Please help me.

Give links to your modules and post your code

This is my code:

#include <TM1637Display.h>

#define interruptPin  2
#define DIO 4    
#define CLK 5    

int m  = 0 ;     // m = minute
int s1 = 0 ;     // s1 = second 1st digit
int s2 = 0 ;     // s2 = second 2nd digit
int d   = 0 ;     // d = decade of second
int c   = 0 ;     // c = Counter
volatile int s  = 1 ;     // s = state of touch pads
uint8_t Time[] = { 0, 0, 0, 0 } ;
unsigned long interval = 100 ;     // the time we need to wait
unsigned long PM = 0 ;  // millis() returns an unsigned long  - PM = Previous Millis()
TM1637Display display(CLK, DIO) ;  // set up the 4-Digit Display

void setup()
{
  attachInterrupt(digitalPinToInterrupt(interruptPin), ST, HIGH);
  display.setBrightness(0x0a) ;  // set the diplay to maximum brightness
}

void loop()
{
 unsigned long CM = millis() ;   // grab current time  / CM = Current Millis
  if ( s % 2 = 0 )
  {
    if ( ( unsigned long ) ( CM - PM ) >= interval )  // check if "interval" time has passed (1000 milliseconds)
     {                        
        d = c / 100 ;
        if ( d > 9 ) 
         {
           c = 0 ;
           d = 0 ;           
           s2 ++ ;         
            if ( s2 > 9 )
             {
              s2 = 0 ;
              s1 ++ ;
               if ( s1 > 5 )
               {
                  s1 = 0 ;
                  m ++ ;            
               }
             }
         }
         Time[0] = display.encodeDigit(m) ;
         Time[1] = display.encodeDigit(s1) ;
         Time[2] = display.encodeDigit(s2) ;
         Time[3] = display.encodeDigit(d) ;
         display.setSegments(Time) ;
         c += 100 ;
     }
        PM = CM ;
   }
}

void ST()
{
  s += s ;
}

Have you tried adding some Serial.print()s so that you can see what is going on ?

Is the interrupt ever triggered, for instance ?

s += s;

You start with s equals 1

So the sequence is 1, 2, 4, 8, 16, ...

Except for the first one, they are all even. Is that the intention?

Further I find it advisable not to use single character variable names; if s represents state, call it state. And that's especially the case with global variables.

reply to: Have you tried adding some Serial.print()s so that you can see what is going on ?

Is the interrupt ever triggered, for instance ?

Yes the interrupt was triggered.

I changed my code to this:

const byte interruptPin = 2 ;

void setup()
{
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(interruptPin), LastState, HIGH) ;
}

void loop() { }

 void LastState()
{
  Serial.print( "Interrupt triggered... " ) ;
}

and when I touch the touch pads, there was written "Interrupt triggered... Interrupt triggered..." in the serial monitor. !!!
When I put my fingers on the touch pads, the first "Interrupt triggered..." typed on serial monitor and when I remove fingers, the second "Interrupt triggered..." typed on serial monitor. !!

it's not a good idea to try to print in the interrupt...

why would a second interrupt be triggered when you remove your fingers if you wait for HIGH? (I suppose you are on a UNO or similar architecture where HIGH should not be used for ISR)

is your module something like this:

I changed my code to this:

Simplifying is good. I would back up one step further and experiment with your sensors using digitalRead(). Can you see the transitions?. Do you see any "bounce"? Are you going to need any pull ups or pull down resisitors, or when the sensor signal is LOW and the sensor is not touched is it grounded or floating? With the two sensors connected as you have to the input pin, does it take both to see a HIGH or LOW state with digitalRead() or will just one trigger a reading.

I would be sure to understand the sensors and the wiring in the most simple configuration before developing the sketch.

I hope you realize that the interrupt mode HIGH is the same as CHANGE.

Also, printing from within an interrupt service routine is bad practice because the serial output depends on interrupts, and interrupts are disabled within the ISR.

cattledog:
I hope you realize that the interrupt mode HIGH is the same as CHANGE.

is it ?
(cf the doc)

mode: defines when the interrupt should be triggered. Four constants are predefined as valid values:

LOW to trigger the interrupt whenever the pin is low,
CHANGE to trigger the interrupt whenever the pin changes value
RISING to trigger when the pin goes from low to high,
FALLING for when the pin goes from high to low.
The Due, Zero and MKR1000 boards allows also:
HIGH to trigger the interrupt whenever the pin is high.

on a standard Arduino indeed HIGH is 1 and CHANGE is defined as 1 too

#define HIGH 0x1
#define LOW  0x0

....

#define CHANGE 1
#define FALLING 2
#define RISING 3

Now If you go to a MKR1000 for example then in WInterrupts.h you'll see

//      LOW 0
//      HIGH 1
#define CHANGE 2
#define FALLING 3
#define RISING 4

so depends on architecture.

so depends on architecture.

If the OP is using an arduino which implements a HIGH interrupt, the I would think it will be constantly triggered while the input is HIGH (like a LOW interrupt is) then that will explain the repeated triggering seen.

It doesn't sound like a correct mode for the application of detecting an timing a touch.