I'm trying to learn how to program a MC, so maybe I didn't know much about a MC. I tried to test interrupt pin of ATtiny85 with this simple code
#include <avr/io.h>
#include <avr/interrupt.h>
void setup()
{
GIMSK = 0b00100000;
PCMSK = 0b00000001;
sei();
DDRB = 0b00010000;
}
void loop()
{
PORTB = 0b00010000;
_delay_ms(500);
PORTB = 0b00000000;
_delay_ms(500);
}
ISR(PCINT0_vect)
{
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
PORTB = 0b00010000;
_delay_ms(100);
PORTB = 0b00000000;
_delay_ms(100);
}
This is just a blink code with an interrupt to make the LED blink faster 10 times. My question is why sometimes the LED blink faster many times with the interrupt pin is not connected to anything (open)? Didn't it have internal pull up or should I use external pull up in my circuit?
Thank you