#define BTN_PIN 4
bool pState = false;
int count=0;
void setup() {
Serial.begin(9600);
pinMode(BTN_PIN, INPUT);
}
void loop()
{
bool state=digitalRead(BTN_PIN);
if (pState!=state)
{
pState=state;
if (state==true)
{
count++;
Serial.print("Кнопка нажата: ");
Serial.println(count);
}
}
delay(50);
}