Hello!
I am working in a pin change interrupt code with an atmega168. whenever it is high, it will light up an LED, however, I don't know how to trigger an interrupt whenever the pin goes low.
Does someone knows how to do this?
This is my code:
volatile int32_t count = 0; int count2 = 0; void setup() { PCMSK2 |= (1<<PCINT18); PCICR |= (1<<PCIE2); PCIFR = (1<<PCIF2); sei(); } ISR(PCINT2_vect) { count=1; } int main() { setup(); //While loop is constantly turning off the LED until the //interrupt is fired while(1) { if( count ==1 ) { DDRB |= (1<<PB3); } else DDRB &= ~(1<<PB3); if( count2 >= 2 && count2 <= 4 ) { //DDRB |= (1<<PB3); } count = 0; } return 0; }