Author Topic: Problem with external interrupt of ATtiny85  (Read 4077 times)

Mahimna

  • Newbie
  • *
  • Posts: 16
Problem with external interrupt of ATtiny85
« on: April 26, 2018, 05:33:29 am »
I am trying a simple LED circuit on tinkercad to simulate using attiny but it is failing. The LED here are just the representation of original project as there the concept is same but LEDs are to be replaced by other electronic part. I'll attach the image of the circuit as well.
I read the basic information and I found that ATTiny85 has only one external interrupt at pin7 i.e PB2. I have used the attachinterrupt function for activation, but unfortunately the interrupt is not getting detected at all, no matter how many times I press the button it is not enterrring in ISR. I tried debugging but my newbie brain was not of much help. Please do help me with circuit and code and where I have went wrong. Thank You!
Code: [Select]

int i_boostButton = 2;
volatile byte vi_boostFlag = LOW;

void setup()
{
 
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, INPUT);
  pinMode(2, INPUT);
 
  attachInterrupt(i_boostButton, boostedOutput, RISING);
 }

void boostedOutput()

 
  vi_boostFlag = HIGH;

}

void loop()

if(digitalRead(4) == HIGH)
  {
  digitalWrite(1, LOW);
        digitalWrite(0, HIGH);
  }
 
  if(digitalRead(4) == LOW)
  {
  digitalWrite(0, LOW);
        digitalWrite(1, HIGH);
  }
 
  if(vi_boostFlag == HIGH)
  {
digitalWrite(0, LOW);
        digitalWrite(1, LOW);
        digitalWrite(3, HIGH);
        delay(5000);
        digitalWrite(3, LOW);
        vi_boostFlag = LOW;
  }
}


I know that it appears as if ISR is doing nothing and a simple deigitalRead will sort the problem but the code I have written here is just a gist and it gets into different loops with selected room size for the detailed final version and so I can not use digitalRead, I want it to be as an interrupt. Please help !

MrCookie

  • Newbie
  • *
  • Posts: 21
Re: Problem with external interrupt of ATtiny85
« Reply #1 on: May 09, 2018, 11:37:15 am »
Weird, I read online that PB1 is the interrupt pin. From this page:
https://arduino.stackexchange.com/questions/3929/attiny85-interrupt-id-vs-pin-when-programming-with-arduino

Can you try that? I only have the Digispark Pro. :X

Mahimna

  • Newbie
  • *
  • Posts: 16
Re: Problem with external interrupt of ATtiny85
« Reply #2 on: May 09, 2018, 12:10:13 pm »
No i got that thanx, i have declared the attach incorrectly.