Well, I am basically trying to learn about interrupts so made a basic circuit with an ATTiny85 with a Red LED on digital 3 (PB2) and a green LED on digital pin 4 (PB3).
I have a 100ohm resisted wire from the 5v rail supply being used to "flip" PB5 (digital 0) pins logic. I was expecting the LEDs to alternate depending on wether I have bothered to change the logic in the last second...
The red LED stays on no matter what!
I have annotated my code with some references I have gotten in the datasheet...
volatile unsigned long some_variable;
ISR(PCINT0_vect) {
some_variable=1;
}
void setup()
{
SREG = 0b10000000; //Set bit I to 1 in SREG byte (AVR Status Register). 4.4.1 in datasheet. -> Enables interrupts.
MCUCR = 0b00000001; // A change in pin logic will cause the ISR to be initiated (9.3.1 in datasheet).
GIMSK = 0b01000000; // Enable pin change interrupt Table 9.3.2
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, INPUT);
}
void loop () {
if (some_variable=1){
digitalWrite(3, HIGH);
digitalWrite(4,LOW);
}
else
{
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
}
delay(1000);
some_variable=0;
} //loop