#include <avr/io.h>
#include <avr/interrupt.h>
// This sketch reads Nano pin 12 and mirrors it onto pin 13.
// I'm not sure even this will be fast enough to mirror WS2812 protocol.
// This function will be called each time PB4 changes level
ISR(PCINT0_vect) {
if (PINB & (1<<PINB4)) // if PINB4 is high
PORTB |= (1<<PORTB5); // set PINB5 high
else
PORTB &= ~(1<<PORTB5); // set PINB5 low
}
int main(void) {
cli(); // disable interrupts during setup
DDRB |= (1 << PB5); // set PB5 as output pin (nano pin 13)
DDRB &= ~(1 << DDB4); // set PB4 as an input pin (nano pin 12)
PCMSK0 |= (1 << PCINT4); // set pin-change mask for interrupt 4
PCICR |= (1 << PCIE0); // enable pin-change interrupt
sei(); // enable interrupts
while (1) {
}
}