/* pcint test using attiny84 sitting in a attino x45 programmer Thanks to The Wandering Engineer for this one; http://thewanderingengineer.com/2014/08/11/pin-change-interrupts-on-attiny85/ */ #include "avr/interrupt.h" volatile int val=LOW; void setup() { pinMode(7,INPUT); //this is the PCINT3 pin @ portA/PCINT0, see http://42bots.com/tutorials/programming-attiny84-attiny44-with-arduino-uno/ // and https://c2.staticflickr.com/8/7054/6897568559_599ecce4d4.jpg digitalWrite(7,HIGH); pinMode(10,OUTPUT); GIMSK = 0b00010000; // turns on pin change interrupts on PCMSK0 PCMSK0 = 0b00001000; // turn on interrupts on pins PCINT7:0 ->> PA3 -> pin 10 sei(); // enables interrupts } void loop() { //dummy } ISR(PCINT0_vect) { val = digitalRead(10); // read input value if (val == HIGH) { // check if the input is HIGH (button released) digitalWrite(10, LOW); // turn LED OFF } else { digitalWrite(10, HIGH); // turn LED ON } }