#include #define rxPin 0 #define txPin 1 SoftwareSerial Serial(rxPin, txPin); int pressLength = 0; //the value for how long the button is pressed down int buttonPin = 3; // button is on pin 3 void setup() { pinMode(rxPin, INPUT); //rx is the input pinMode(txPin, OUTPUT); //tx is the output pinMode(buttonPin, INPUT_PULLUP); //the button is a input pullup (to activate internal resistor) Serial.begin(9600); } void loop(){ while (digitalRead(buttonPin) == LOW ){ delay(100); pressLength = pressLength + 100; Serial.println(pressLength); } if (digitalRead(buttonPin) == HIGH ){ } pressLength = 0; //reset the pressLength every loop }