Counter doesn't continue

Dear Forum Members,
This will be the first time I approach the knowledge of the many Forum members.
While a sketch for the control of two stepper motors and a solenoïde is working perfectly, I cannot get the counter working. Attached the code which shows on the display, a LCD_I2C connected to a Arduino UNO Rev.3, doesn’t add the counts. Each of the buttons, the (touchPin) resp. the (resetPin), are connected to a pulldown resistor 10k. The verification of the code and the upload show ”success”
Where can I find the bug? I would appreciate your assistance.

https://create.arduino.cc/editor/NassauLv/ce25d0c9-36c8-4a7d-8c30-6472cc80093f/preview
code:

/Sketch_mar4a; Code for counting and resetting/
// Start of setting for lcd with i2c

// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // Change to (0x27,16,2) for 16x2 LCD.
// End of settings for LCD 1602 with I2C

const int touchPin = 8; // Input Pin for touch sensor
const int resetPin = 3; // Resetting
const int touchDelay = 500; // minimum ms between each touch
int count = 0; // variable holding the count number

void setup(){
// initializa the LCD
lcd.init();
lcd.backlight(); // turn backlight on
lcd.print (“Aantal”);
lcd.setCursor (0,1);
lcd.print (“ontpitproduct”);
Serial.begin(9600); //initialize monitor
Serial.println ("");
pinMode (touchPin, INPUT); // define pin for touchpad

}
void loop(){
int touchValue = digitalRead(touchPin); // read touch pinand store it in touchValue
// if touchValue is HIGH
if(touchPin == HIGH)

delay(500);
{

count++; //increment the count
lcd.clear(); //clean previous value from screen
lcd.print (“Aantal”);
lcd.setCursor(0,1);
lcd.print (“ontpit”);
lcd.setCursor(9,1);
lcd.print(count);

Serial.print(“Aantal”);
Serial.println(“ontpit”);
Serial.print(count);
delay(touchDelay); //touch delay time
}
// if reset switch is pressed

lcd.clear(); // clear previous valus from screen
count = 0; //reset counter
Serial.println (“Counter resetted”); //print info
lcd.setCursor (0,0);

lcd.print (“recounting”);
lcd.setCursor (0,1);
lcd.print (“Resetted”);

}

  if (touchPin == HIGH)

Look very carefully at the variable you are testing here

Is it the pin number or the state of the pin that you have previously read ?

Hello UKHeliBob,
thanks for your reply. Please give me more information after reading my code now included in my post.

From your code

   int touchValue = digitalRead(touchPin); // read touch pinand store it in touchValue
    // if touchValue is HIGH
    if(touchPin == HIGH)

You read the state of the pin using digitalRead() and assigning the value to the touchValue variable. All OK so far. Then you seem to have correctly commented ejat you intended to do but commented it out and instead you test the value of touchPin which will not change from its initial value of 8. Test the value of touchValue instead

That is certainly what I said

UKHeliBob:
That is certainly what I said

UKHeliBob:
That is certainly what I said

Despite your advise I noticed that the counts do not react upon the buttons (touchpin and resetpin) HIGH or LOW. If I remove the clearing at the end of the code the counting just continues. Sorry, but I am stil in problem.

Post your code as it is now