Basically I want to have a button with 2 functions. If it is pressed for less than two seconds, do action A. If it is pressed for more than two seconds, do action B. I have this code but it doesn't seem to work
int button = 7;
int buttonState = 0;
int lastButtonState = LOW;
long previousMillis = 0;
long interval = 100;
unsigned long duration;
void setup() {
 pinMode (7, INPUT);
}
void loop() {
 buttonState = digitalRead (button);
 unsigned long currentMillis = millis();
Â
 if (buttonState == LOW) {
  lastbuttonState = LOW;
 }
if (buttonState == HIGH) && (lastButtonState == LOW) && (currentMillis - previousMillis > interval)) {
  duration = pulseIn (7, HIGH);
  if (duration < 2000000) {
   "do action A"  Â
   lastButtonState = HIGH;
   previousMillis = currentMillis;
  }
  if (duration > 2000000) {
   "do action B"
   lastButtonState = HIGH;
   previousMillis = currentMillis;
  }
 }
}
what am I doing wrong?