/* Into Robotics */ const int lowerThreshold = 250; const int upperThreshold = 450; const uint8_t analogPin = A0; void setup() { Serial.begin(9600); pinMode(analogPin, INPUT); } void loop() { static bool state = LOW; static unsigned int counter = 0; int analogValue = analogRead(analogPin); if (state == HIGH) { if (analogValue < lowerThreshold) { state = LOW; counter++; Serial.println(counter); Serial.println("blykst"); } } else { // state == LOW if (analogValue > upperThreshold) { state = HIGH; } } }