timer1 on attiny85

hi all

basically i want to use this code on my attiny85, but timer1 is not compatible to attiny85, anyway to re-modify this code? thanks.

#include <TimerOne.h>

int latchPin = 1; //Pin connected to Pin 12 of 74HC595 (Latch)
int clockPin = 2; //Pin connected to Pin 11 of 74HC595 (Clock)
int dataPin = 0; //Pin connected to Pin 14 of 74HC595 (Data)
byte frame = 0;  // variable to store the current frame being displayed

byte led[8][8] = { {0, 120, 72, 120, 8, 10, 14, 0}, // 8 frames of an animation
                      {0, 120, 72, 120, 8, 10, 14, 0},
                      {0, 120, 72, 120, 8, 10, 14, 0},
                      {0, 120, 72, 120, 8, 10, 14, 0},
                      {0, 120, 72, 120, 8, 10, 14, 0},
                      {0, 120, 72, 120, 8, 10, 14, 0},
                      {0, 120, 72, 120, 8, 10, 14, 0},
                      {0, 120, 72, 120, 8, 10, 14, 0} };

void setup() {
        pinMode(latchPin, OUTPUT);  // set the 3 digital pins to outputs
        pinMode(clockPin, OUTPUT);
        pinMode(dataPin, OUTPUT);

        Timer1.initialize(10000); // set a timer of length 10000 microseconds 
        Timer1.attachInterrupt(screenUpdate); // attach the screenUpdate function
}

void loop() {
        for (int i=0; i<8; i++) { // loop through all 8 frames of the animation
                for (int j=0; j<8; j++) { // loop through the 8 rows per frame
                        led[i][j]= led[i][j] << 1 | led[i][j] >> 7; // bitwise rotation
                }
        }
        frame++; // go to the next frame in the animation
        if (frame>7) { frame =0;} // make sure we go back to frame 0 once past 7
        delay(250); // wait a bit between frames
}

void screenUpdate() { // function to display image
        byte row = B10000000; // row 1
        for (byte k = 0; k < 9; k++) {
          digitalWrite(latchPin, LOW); // open latch ready to receive data

                shiftIt(~led[frame][k] ); // LED array (inverted)
                shiftIt(row); // row binary number

                // Close the latch, sending the data in the registers out to the matrix
                digitalWrite(latchPin, HIGH);
                row = row >> 1; // bitshift right
        }
}

void shiftIt(byte dataOut) {
        // Shift out 8 bits LSB first, on rising edge of clock

        boolean pinState; 

        //clear shift register read for sending data
        digitalWrite(dataPin, LOW);

        // for each bit in dataOut send out a bit
        for (int i=0; i<8; i++)  {
                //set clockPin to LOW prior to sending bit
                digitalWrite(clockPin, LOW);

                // if the value of DataOut and (logical AND) a bitmask
                // are true, set pinState to 1 (LOW)
                if ( dataOut & (1<<i) ) {
                        pinState = LOW;
                }
                else {
                        pinState = HIGH;
                }

                //sets dataPin to HIGH or LOW depending on pinState
                digitalWrite(dataPin, pinState);
                //send bit out on rising edge of clock 
                digitalWrite(clockPin, HIGH);
                digitalWrite(dataPin, LOW);
        }

digitalWrite(clockPin, LOW); //stop shifting
}

Blink without delay.

thanks for the reply, but sorry... i don't understand that, can you show me how is it please?

I'm willing to help you but not do it for you. If you would like my help you need to at least make an attempt.

You don't need an interrupt for this. Just call "screenUpdate()" whenever the value of "millis()" changes.

The TimerOne/Timer1 library does not work but the Timer1 is on the ATtiny85, you just have to program it through other library(ies) or directly low level. Google Nick Gammon ATtiny85 timer for some code.