Interrupts on attiny85

I’ve wrote a sketch for a flashlight, and now I’m trying to port it from the arduino to an Attiny85. I’m using this tutorial:

Programming the attiny works. (tested with the blink sketch)
But now my interrupt doesn’t work. I’m using interrupt 0 with the internal pull-up and according to the datasheet of the attiny85 int0 is on pin7

#include <avr/sleep.h>

byte ledpin=0;  //pinnen definieren
byte drukknop=0;
volatile boolean ledStatus;  //volatile gebruiken doordat deze moet aangesproken worden in de interrupt methode
byte aantalDrukken;
long timer1;  //variabele om aantal milliseconden weg te schrijven
long timer2;

//pinksnelheid in milliseconden:
int pinksnelheid=500;
//debouncetijd in milliseconden:
int debounce=200;
int standbytijd=1000;

void setup(){
  pinMode(drukknop,INPUT);  //inputs en outputs definieren
  digitalWrite(drukknop,HIGH); // interne pull-up aanzetten
  ledStatus=false;      //led om te beginnen uitzetten
  aantalDrukken=0;      //beginnen 
  attachInterrupt(0,knop,FALLING);      //interrupt 0 (digital pin 2) koppelen aan de routine

void loop(){                          //Main loop die de status controleert en naargelang de led aan, uit of laat pinken
  pinken();                            //verwijst naar de pinkroutine  

void knop(){                            //interrupt routine om te zorgen voor de input van de drukknop
  delay(debounce);                           //debouncetijd van 200 milliseconden
  if(aantalDrukken>=3)                  //aantalDrukken bevat het cijfer dat de modus aanduid: 0= uit, 1= aan, 2=pinken
  aantalDrukken=0;                      //aantalDrukken moet terug naar 0 gaan wanneer hij op 3 komt

void pinken(){                            //code om te pinken zonder gebruik te maken van delay's
  if(millis()-timer1>pinksnelheid){              //Delay's zouden code stilleggen en de input verstoren. Of onregelmatig maken.
    ledStatus= !ledStatus;

void standby(){
  //  Serial.println("powering down"); 
  //  Serial.println("waking up");

What could I be doing wrong?

You seem to be using Pin 0 for both the ledpin and drukknop. If the interrupt is on physical pin 7 you probably want drukknop to be 2.

Also note that "attachInterrupt()" is not listed as supported on the page you reference.

According to the datasheet, you can use any pin for interrupting. And it is really simple to set it up (after reading it over and over many times). One thing to note though is that all pins configured to fire the interrupt will fire the same ISR (interrupt service routine) so you would need to check which pin changed in here to figure out what to do.

So first things first: add the following 3 lines of code to your setup() function:

   GIMSK = (1 << PCIE); //Enable Pin Change Interrupts 
   PCMSK = (1 << PCINT2); //Set Pin 2 to cause an interrupt. You can also enable it on multiple pins 

Now write the ISR:

ISR (PCINT0_vect)       //the PCINT0_vect vector is used to identify the pin change interrupt.
    if (PINB & (1 << PCINT2)) {  // check if Pin2 is HIGH or not
	//Do something
    } else {
	//Do something else

Remember to keep your ISR’s as short as possible, i.e. you can set flags in your ISR, and then do heavy processing in your main loop if you detect the flags are set, and clear them after they have been processed.

Hi, I was wondering how you completed the sketch for the flashlight with the interrupt. I am trying something similar but got stuck with the coding on PCINT3