attiny85 interrupt

I’m trying to get the following code onto an attiny85, I’m stuck on the arduino interrupt to attiny85 interrupt. An error is thrown see error below in and I’m not sure what to do to solve this. Searching I’ve found a lot of information but it’s not making sense to me not sure where to implement in my code.

LINKs:

<this one seems good but I’m not sure where I would implament in my code> Pin Change Interrupts on ATtiny85 – The Wandering Engineer

arduino setup:
board: attiny25/45/85
processor: attiny85
clock: internal 8 MHz
programer: arduino as isp

ideal outcome: the user presses a push button to cycling through 4 led animations.

#include <Adafruit_NeoPixel.h>

#define PIN 0 // 9 // 0 for attiny85, 9 for uno
#define NUMPIXELS 8
#define button1Pin 1 // 2 // 1 for attiny85, 2 for uno

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB);

//define some colors
uint32_t red = pixels.Color(255, 0, 0);
uint32_t yellow = pixels.Color(255, 255, 0);
uint32_t orange = pixels.Color(255, 165, 0);
uint32_t green = pixels.Color(0, 255, 0);
uint32_t blue = pixels.Color(0, 0, 255);
uint32_t purple = pixels.Color(255, 0, 255);
uint32_t black = pixels.Color(0, 0, 0);

// delay var
int delayval = 100;

// var to read button presses from user
int count = 0;

void setup() {

//start neopixels
pixels.begin();

attachInterrupt(digitalPinToInterrupt(button1Pin), buttonPress, RISING);

/*
this line above throws this error

/Documents/Arduino/Pak_test/Pak_test.ino: In function ‘void setup()’:
Pak_test:28:51: error: ‘digitalPinToInterrupt’ was not declared in this scope
attachInterrupt(digitalPinToInterrupt(button1Pin), buttonPress, RISING);
^
exit status 1
‘digitalPinToInterrupt’ was not declared in this scope
*/

//give things a second to get started
delay(1000);
}

//interrupt function
// used to detect user input to change led animation

void buttonPress() {
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 200ms, assume it’s a bounce and ignore
if (interrupt_time - last_interrupt_time > 250){
// button push counter
count += 1;
}
last_interrupt_time = interrupt_time;
}

//custom led animations
int rainbow(int n, int dir){

long colors[15][8] = {
{black,black,black,black,black,black,black,black},
{purple,black,black,black,black,black,black,black},
{blue,purple,black,black,black,black,black,black},
{green,blue,purple,black,black,black,black,black},
{orange,green,blue,purple,black,black,black,black},
{yellow,orange,green,blue,purple,black,black,black},
{red,yellow,orange,green,blue,purple,black,black},
{black,red,yellow,orange,green,blue,purple,black},
{black,black,red,yellow,orange,green,blue,purple},
{black,black,black,red,yellow,orange,green,blue},
{black,black,black,black,red,yellow,orange,green},
{black,black,black,black,black,red,yellow,orange},
{black,black,black,black,black,black,red,yellow},
{black,black,black,black,black,black,black,red},
{black,black,black,black,black,black,black,black}
};
//loop animation n times

switch (dir) {
case 1:
for(int i = 0; i < n; i++){
for(int a = 14; a>-1;a–){
for( int b=0; b<8; b++){
pixels.setPixelColor(b,colors[a]);
** pixels.show();**
** }**
** if (a==7){**
** fade(3);**
** }**
** delay(200);**
** }**
** }**
** break;**

** case 0:**
** for(int i=0; i<n; i++){**
** for(int a=0; a<15; a++){**
** for( int b=0; b<8; b++){**
__ pixels.setPixelColor(b,colors[a]);__
** pixels.show();**
** }**
** if (a==7){**
** fade(3);**
** }else{**
** delay(200);**
** }**
** }**
** pixels.clear();**
** }**
** break;**

** }**
}
int hotFuzzFlash(int n){
** for(int x = 0; x < n; x++){**
** for(int i = 0; i < 4; i++){**
** pixels.setPixelColor(i,pixels.Color(254,0,0));**
** }**
** pixels.show();**
** delay(random(200));**

** for(int h = 0; h < 4; h++){**
** pixels.setPixelColor(h,pixels.Color(0,0,0));**
** }**
** pixels.show();**
** delay(random(200));**

** for(int i = 4; i < 8; i++){**
** pixels.setPixelColor(i,pixels.Color(0,0,254));**
** }**
** pixels.show();**
** delay(random(200));**

** for(int h = 4; h < 8; h++){**
** pixels.setPixelColor(h,pixels.Color(0,0,0));**
** }**
** pixels.show();**
** delay(random(200));**
** }**

}
int hotFuzzRun(int n){
** for(int x = 0; x < n; x++){**
** for(int y=3,z=4;(y>-1) && (z<8); y–,z++){**
** pixels.setPixelColor(y, 255,0,0); //pixels.Color(254,0,0));**
** pixels.setPixelColor(z, pixels.Color(0,0,254));**
** pixels.show();**
** delay(150); **
** }**

** for(int k = 0; k<8;k++){**
** pixels.setPixelColor(k, pixels.Color(0,0,0));**
** pixels.show();**
** }**
** delay(100);**
** }**
}
int fade(int n){
** for(int i=0; i<n; i++){**
** for(int a = 0; a < 255; a++){**
** pixels.setPixelColor(1,pixels.Color(a,0,0));//red**
** pixels.setPixelColor(2,pixels.Color(a,a,0));//yellow**
** pixels.setPixelColor(3,pixels.Color(a,map(a,0,255,0,165),0));//orange**
** pixels.setPixelColor(4,pixels.Color(0,a,0));//green**
** pixels.setPixelColor(5,pixels.Color(0,0,a));//blue**
** pixels.setPixelColor(6,pixels.Color(a,0,a));//purple**
** pixels.show();**
** delay(2);**
** }**
** for(int c = 254; c > -1; c–){**

** pixels.setPixelColor(1,pixels.Color(c,0,0));//red**
** pixels.setPixelColor(2,pixels.Color(c,c,0));//yellow**
** pixels.setPixelColor(3,pixels.Color(c,map(c,0,255,0,165),0));//orange**
** pixels.setPixelColor(4,pixels.Color(0,c,0));//green**
** pixels.setPixelColor(5,pixels.Color(0,0,c));//blue**
** pixels.setPixelColor(6,pixels.Color(c,0,c));//purple**
** pixels.show();**
** delay(2); **

** }**
** }**
}
int randPixl(int n){
** for(int a = 0; a<n;a++){**
** for(int x = 0; x < 8; x++){**
** pixels.setPixelColor(random(0,8),random(255),random(255),random(255));**
** pixels.show();**
** delay(random(255));**
** }**
** pixels.clear();**
** }**
}
int Scan(int n){
** for(int x = 0; x<n;x++){**
** int delayVal = 100;**
** pixels.setPixelColor(0,black);**
** pixels.show();**
** delay(delayVal+100);**
** for(int a = -1;a<9;a++){**

** pixels.setPixelColor(a-1,15,0,0);**
** pixels.setPixelColor(a,red);**
** pixels.setPixelColor(a+1,15,0,0);**
** pixels.show();**
** delay(delayVal);**
** pixels.clear();**
** }**

** pixels.setPixelColor(7,black);**
** pixels.show();**
** delay(delayVal+100);**

** for(int b = 8;b>-2;b–){**

** pixels.setPixelColor(b+1,15,0,0);**
** pixels.setPixelColor(b,red);**
** pixels.setPixelColor(b-1,15,0,0);**
** pixels.show();**
** delay(delayVal);**
** pixels.clear();**
** }**
** }**

}
//loop start
void loop() {
** // use count and modulo to cycle led animation**
** switch (count%4){**
** case 0:**
** Scan(1);**
** break;**
** case 1:**
** randPixl(1);**
** break;**
** case 2:**
** hotFuzzFlash(1);**
** hotFuzzRun(1);**
** break;**
** case 3:**
** rainbow(1,0);**
** rainbow(1,1);**
** break;**
** }**
}

...and that's why you need to use code tags when posting code.

Use my ATTinyCore instead of whatever core you are using. It has included digitalPinToInterrupt() macro since 1.1.3 (may 2016).

Thanks DrAzzy for pointing me to your core.

as I was looking at the github repo I noticed this line of code in file ATTinyCore/Internals.md

#define DISABLE_UART (1 = disables HW serial buffers and interrupts)

what do I have to do to enable interrupts, is it enabled by default, did I overlook how to enable this setting in the documentation?

DrAzzy I got it had the wrong pin for interrupt. Thanks again.

For everyone else this is my updated code that works.
this link helped me: ATTiny85 arduino interrupt - Arduino Stack Exchange

#include <Adafruit_NeoPixel.h>

#define PIN            0 // 0 for attiny85, 9 for uno
#define NUMPIXELS      8
#define button1Pin     2 // 2 for attiny85, 2 for uno

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB);

//define some colors
uint32_t red = pixels.Color(255, 0, 0);
uint32_t yellow = pixels.Color(255, 255, 0);
uint32_t orange = pixels.Color(255, 165, 0);
uint32_t green = pixels.Color(0, 255, 0);
uint32_t blue = pixels.Color(0, 0, 255);
uint32_t purple = pixels.Color(255, 0, 255);
uint32_t black = pixels.Color(0, 0, 0);

// delay var
int delayval = 100;

//button press counter   
int count = 0;

volatile byte buttonPressed = false;

void setup() {
  //start neopixels
  pixels.begin();
  
  pinMode(button1Pin, INPUT);
  attachInterrupt(digitalPinToInterrupt(button1Pin), buttonPress, RISING);
  //give things a second to get started, why not?
  delay(1000);
}

//interrupt function
void buttonPress() {
  
// change buttonPressed to true
  buttonPressed = !buttonPressed;
  
  static unsigned long last_interrupt_time = 0;
  unsigned long interrupt_time = millis();
  // If interrupts come faster than 200ms, assume it's a bounce and ignore
  if (interrupt_time - last_interrupt_time > 250){
    count += 1;
  }
  last_interrupt_time = interrupt_time;
}



//custom functions
int rainbow(int n, int dir){

  long colors[15][8] = {
  {black,black,black,black,black,black,black,black},
  {purple,black,black,black,black,black,black,black},
  {blue,purple,black,black,black,black,black,black},
  {green,blue,purple,black,black,black,black,black},
  {orange,green,blue,purple,black,black,black,black},
  {yellow,orange,green,blue,purple,black,black,black},
  {red,yellow,orange,green,blue,purple,black,black},
  {black,red,yellow,orange,green,blue,purple,black},
  {black,black,red,yellow,orange,green,blue,purple},
  {black,black,black,red,yellow,orange,green,blue},
  {black,black,black,black,red,yellow,orange,green},
  {black,black,black,black,black,red,yellow,orange},
  {black,black,black,black,black,black,red,yellow},
  {black,black,black,black,black,black,black,red},
  {black,black,black,black,black,black,black,black}
  };
  //loop animation n times
  

    switch (dir) {
      case 1:
        for(int i = 0; i < n; i++){
          for(int a = 14; a>-1;a--){
            for( int b=0; b<8; b++){
              pixels.setPixelColor(b,colors[a][b]);
              pixels.show();
            }
            if (a==7){
              fade(3);
            }
            delay(200);
          }
        }
      break;
      
      case 0:
        for(int i=0; i<n; i++){
          for(int a=0; a<15; a++){
            for( int b=0; b<8; b++){
              pixels.setPixelColor(b,colors[a][b]);
              pixels.show();
            }
            if (a==7){
              fade(3);
            }else{
              delay(200);
            }
          }
          pixels.clear();
        }
      break;
    
  }
}

int hotFuzzFlash(int n){
  for(int x = 0; x < n; x++){
    for(int i = 0; i < 4; i++){
      pixels.setPixelColor(i,pixels.Color(254,0,0));
    }
      pixels.show();
      delay(random(200));
    
     for(int h = 0; h < 4; h++){
      pixels.setPixelColor(h,pixels.Color(0,0,0));
     }
      pixels.show();
      delay(random(200));
  
    for(int i = 4; i < 8; i++){
      pixels.setPixelColor(i,pixels.Color(0,0,254));
    }
      pixels.show();
      delay(random(200));
    
     for(int h = 4; h < 8; h++){
      pixels.setPixelColor(h,pixels.Color(0,0,0));
     }
      pixels.show();
      delay(random(200));

  }
 
}

int hotFuzzRun(int n){
  for(int x = 0; x < n; x++){
    for(int y=3,z=4;(y>-1) && (z<8); y--,z++){
      pixels.setPixelColor(y, 255,0,0); //pixels.Color(254,0,0));
      pixels.setPixelColor(z, pixels.Color(0,0,254));
      pixels.show();
      delay(150);      
    }
    
    for(int k = 0; k<8;k++){
      pixels.setPixelColor(k, pixels.Color(0,0,0));
      pixels.show();
    }
    delay(100);
  }
}

int fade(int n){
  for(int i=0; i<n; i++){
    for(int a = 0; a < 255; a++){
        pixels.setPixelColor(1,pixels.Color(a,0,0));//red 
        pixels.setPixelColor(2,pixels.Color(a,a,0));//yellow
        pixels.setPixelColor(3,pixels.Color(a,map(a,0,255,0,165),0));//orange
        pixels.setPixelColor(4,pixels.Color(0,a,0));//green
        pixels.setPixelColor(5,pixels.Color(0,0,a));//blue
        pixels.setPixelColor(6,pixels.Color(a,0,a));//purple
        pixels.show();
        delay(2); 
    }
    for(int c = 254; c > -1; c--){
      
        pixels.setPixelColor(1,pixels.Color(c,0,0));//red
        pixels.setPixelColor(2,pixels.Color(c,c,0));//yellow
        pixels.setPixelColor(3,pixels.Color(c,map(c,0,255,0,165),0));//orange
        pixels.setPixelColor(4,pixels.Color(0,c,0));//green
        pixels.setPixelColor(5,pixels.Color(0,0,c));//blue
        pixels.setPixelColor(6,pixels.Color(c,0,c));//purple
        pixels.show();
        delay(2);      
     
    }
  }
}

int randPixl(int n){
  for(int a = 0; a<n;a++){
    for(int x = 0; x < 8; x++){
      pixels.setPixelColor(random(0,8),random(255),random(255),random(255));
      pixels.show();
      delay(random(255));
    }
    pixels.clear();
  }
}

int Scan(int n){
  for(int x = 0; x<n;x++){
    int delayVal = 100;
    pixels.setPixelColor(0,black);
    pixels.show();
    delay(delayVal+100);
    for(int a = -1;a<9;a++){
      
      pixels.setPixelColor(a-1,15,0,0);
      pixels.setPixelColor(a,red);
      pixels.setPixelColor(a+1,15,0,0);
      pixels.show();
      delay(delayVal);
      pixels.clear();
    }
  
    pixels.setPixelColor(7,black);
    pixels.show();
    delay(delayVal+100);
    
    for(int b = 8;b>-2;b--){
      
      pixels.setPixelColor(b+1,15,0,0);
      pixels.setPixelColor(b,red);
      pixels.setPixelColor(b-1,15,0,0); 
      pixels.show();
      delay(delayVal);
      pixels.clear();
    }
  }
 
}

int text(String myText){
  //display a message in binary
  for(int i=0; i<myText.length(); i++){
    char myChar = myText.charAt(i);
 
    for(int i=7, x=0; (i>=0) && (x<8); i--,x++){
      byte bytes = bitRead(myChar,i);
      if(bytes == 1){
        pixels.setPixelColor(x,pixels.Color(0,0,255));
        pixels.show();
      }else{
        pixels.setPixelColor(x,0,0,0);
        pixels.show();
      }
    }
    delay(2000);
    
    
  }
  for(int a=0;a<8;a++){
    pixels.setPixelColor(a,0,0,0);
    pixels.show();
  }
  delay(2000);
}


//loop start
void loop() { 

//change buttonPressed to false
    if(buttonPressed){
    buttonPressed = !buttonPressed;
  }
  switch (count%4){
    case 0:
    if(buttonPressed)return;
      Scan(1);
    break;
    case 1:
      if(buttonPressed)return;
      randPixl(1);
    break;
    case 2:
      if(buttonPressed)return;
      hotFuzzFlash(5);
      if(buttonPressed)return;
      hotFuzzRun(5);
    break;
    case 3:
      if(buttonPressed)return;
      text("Hello");
    break;
    
  }
}