#include #define rxPin 0 #define txPin 1 SoftwareSerial Serial(rxPin, txPin); int pressLength = 0; //the value for how long the button is pushed down int One = 100; //define the *minimum* length of time, in milli-seconds, that the button must be pressed for a particular option to occur 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; } if (pressLength >= One){ Serial.println(pressLength); } pressLength = 0; //reset the pressLength every loop }