Go Down

Topic: Attiny 45/85 on arduino, will intterrupt work? (Read 9196 times) previous topic - next topic


Oct 10, 2010, 12:27 am Last Edit: Oct 10, 2010, 12:34 am by acmilangr Reason: 1
i tried this and it doesnt works
Code: [Select]
int led_pin =4;
volatile int state = LOW;

void setup()
 pinMode(led_pin, OUTPUT);
 attachInterrupt(0, blink, CHANGE);

void loop()


void blink()
 state = !state;

any other code (digitaWrite,analogRead,delay...) works


What is feeding into pin2 that is generating the interrupt? Does the attiny 45/85 use the same input pin for the interrupt that attachInterrupt is supposed to be watching for?
The art of getting good answers lies in asking good questions.


pin2 on attiny 45 is INT2,

so when i call attachInterrupt(0, blink, CHANGE); i call pin2 right? why i have the problem?


Oct 10, 2010, 05:39 pm Last Edit: Oct 10, 2010, 05:50 pm by RIDDICK Reason: 1
can u find out what the content of the interrupt registers is (before and after the attachInt...() call)?

e. g. MCUCR, GIMSK, PCMSK, ...

maybe u could do it with a flash code?
1: long on, then short off
0: short on, then short off
after 8 bits: long off

or does serial work?



i really dont understand what you mean, i only know some things on arduino



i mean:
in order to analyse the reason why it doesnt work,
we should take a look at some registers...

they will tell u what is going wrong...

the datasheet is nice, 2...

how do u communicate with that attiny?
just with blinking LEDs?

then u might want to try this:
Code: [Select]

void setup() {

void blink(const uint16_t ht, const uint16_t lt) {

void loop {
 uint8_t v = PCMSK;
 blink(3000,1000); // start
 blink(5000,1000); // start
 for (uint8_t i=8; i; i--,v>>=1) { // LSB first

with a LED (and a resistor in series) on pin 4 (at the DIP case it is pin2, iirc)...



i tried to blink on and off a led with some delay, i tried to blink it with a button (using digitalRead) and that worked too


yes - but now it will tell u the content of some interrupt register... -arne


first it will turn on the LED twice for a long time...

then it will turn on the LED for 1sec for a "1"
and for 500msec for a "0"...

after 8 bits u know the content of PCMSK...



I am using external interrupts and they work fine.

I am using RISING rather than CHANGE.

note that there is only interrupt 0 and it's on pin 7 of the attiny85 IC which is Digital i/o pin 2.

i agree you should try a simple led blink sketch to make sure you've got your programmer working and your pin assignments right.


bill2009 how did you try attiny85? with arduino as ISP or AVR?

did you connecteed like that link?



I'm using a separate programmer but if you can get blink to work you're programming it ok.

Make sure you're providing the input on pin 7 of the chip.



Oct 15, 2010, 11:30 pm Last Edit: Oct 15, 2010, 11:31 pm by RIDDICK Reason: 1
congrats!  :D [smiley=thumbsup.gif] [smiley=birthdays.gif]

what was it?


Go Up