#include <avr/io.h>
#include <util/delay.h>
#define INPUT_PIN (1 << PB3) // PB3 as input
#define OUTPUT_PIN (1 << PB1) // PB1 as output
void setup() {
DDRB &= ~INPUT_PIN; // Set PB3 as input
DDRB |= OUTPUT_PIN; // Set PB1 as output
}
void loop() {
static uint8_t highCount = 0; // Counter for high signals
if (PINB & INPUT_PIN) { // If PB3 is high
if (PINB & INPUT_PIN) { // Check again to confirm
highCount++; // Increment high signal counter
if (highCount == 2) { // If two high signals are detected
PORTB |= OUTPUT_PIN; // Set PB1 high
PORTB &= ~OUTPUT_PIN; // Set PB1 low
highCount = 0; // Reset high signal counter
}
}
} else {
highCount = 0; // Reset high signal counterif input is not high
}
}
int main() {
setup();
while (1) {
loop();
}
return 0;
}