#define INTERRUPT_PIN PCINT1 // This is PB1 per the schematic
#define INT_PIN PB1 // Interrupt pin of choice: PB1 (same as PCINT1) - Pin 6
#define LED_PIN PB4 // PB4 - Pin 3
#define PCINT_VECTOR PCINT0_vect // This step is not necessary - it's a naming thing for clarit
void setup() {
pinMode(LED_PIN, OUTPUT);
//cli(); // Disable interrupts during setup
PCMSK = bit(PB1); //(1 << INTERRUPT_PIN); // Enable interrupt handler (ISR) for our chosen interrupt pin (PCINT1/PB1/pin 6)
GIMSK |= bit(PCIE); //(1 << PCIE); // Enable PCINT interrupt in the general interrupt mask
//pinMode(INT_PIN, INPUT_PULLUP); // Set our interrupt pin as input with a pullup to keep it stable
sei(); //last line of setup - enable interrupts after setup
}
// This is the interrupt handler called when there is any change on the INT_PIN
// ISR is defined in the headers - the ATtiny85 only has one handler
ISR(PCINT_VECTOR)
{
if( digitalRead(INT_PIN) == LOW ) {
digitalWrite(LED_PIN, HIGH);
}else{
digitalWrite(LED_PIN, LOW);
}
}
void loop()
{
}