Skip to content

Instantly share code, notes, and snippets.

@busti
Created May 3, 2015 14:01
Show Gist options
  • Save busti/747ed0daa89d3de23ef7 to your computer and use it in GitHub Desktop.
Save busti/747ed0daa89d3de23ef7 to your computer and use it in GitHub Desktop.
#include "avr/interrupt.h"
int inPin = 3;
int outPin = 4;
volatile boolean state = false;
void setup() {
pinMode(inPin, INPUT);
digitalWrite(inPin, HIGH);
pinMode(outPin, OUTPUT);
GIMSK = 0b00100000; // turns on pin change interrupts
PCMSK = 0b00001000; // turn on interrupts on pin PB3
sei();
}
void loop() {
}
ISR(PCINT0_vect) {
digitalWrite(outPin, digitalRead(inPin));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment