Attach interrupt on Falling

I am using ATTiny2313, program with UNO.

I use a switch on attach interrupt input, suppose to be Interrupt on FALLING.
The switch is normally LOW. When switch is tun on, it go High and when the switch is OFF. It shall activate the interrupt because there is a falling from high to low state.

The actual I get when i connected my circuit is the interrupt is turn on when the switch just Turn on instead of Turn OFF. I suspect this is due to glitches on the switch. My code is below.

int ledPin = 0;
long previousMillis = 0;
long interval = 30000; //30 sec

void setup() {
  // put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
attachInterrupt(0, turnOnLed, FALLING);


void loop() {
  // put your main code here, to run repeatedly:

void turnOnLed(){
  unsigned long currentMillis = millis();
  digitalWrite(ledPin, HIGH);//use pwm is better
  if(currentMillis - previousMillis > interval){
    digitalWrite(ledPin, LOW);
    previousMillis = currentMillis;

Is there any solution to this by software as I try to avoid hardware solution.

Try the following before attachInterrupt(...)

pinMode(buttonPin, INPUT | PULLUP);

Or is it PULL_UP....can't remember.

Just try both - you will figure out which one it is from the compiler.

If you don't do what I suggested then the only way your button pin can experience a falling voltage is to experience a rising voltage first.

Which then appears to you as though the interrupt is triggering on a rising voltage.

Or is it PULL_UP....can't remember.