BYTE |= (1<<i); // set a bit
BYTE = (1<<i) | (1<<j); // set two bits
BYTE &= ~(1<<i); // clear a bit
BYTE ^= (1<<i); //toggle a bit (change its state to the opposite)
Here is the demo code but it does not work reliably and needs to be rewritten!:
/*
* Attiny84 interrupt.c
*
* Created: 2/1/2019 12:58:37 PM
* Author : FablabDigiscope
*/
#include <avr/interrupt.h>
#include <util/delay.h>
ISR(INT0_vect)
{
if (PINB & (0b00000100)) // if this works out as non-zero it will execute...
{
PORTA |= 0b00000010; // set interrupt LED on
PORTA &= ~0b00000100; // clear blinking LED bit
}
else
{
PORTA &= ~(0b00000010); // clear interrupt LED bit
}
}
int main (void)
{
PINB = 0b00000100; // pull up resistor for PB2
DDRA = 0b00000110; // two LEDS output
GIMSK |= (1 << INT0); // enable the INT0 external interrupt on pin PB2
sei(); //enable global interrupts
while (1)
{
PORTA ^= 0b00000100; //toggle the blinking light
PORTA &= ~0b00000010; // turn off the interrupt light
_delay_ms(200);
}
}