Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define dataPin 2
- #define outPin 6
- void setup()
- {
- DDRD |= (1<<outPin); //set the pin (6) to be an output... when pin 6 is an output PORTD controlls whether it's high or low with 1 or 0
- DDRD &= ~(1<<dataPin); //Set controllerDataPin (pin 4) to be an input
- PORTD |= (1<<dataPin); //Set controllerDataPin (pin 4) to have a pullup resistor enabled
- attachInterrupt(digitalPinToInterrupt(dataPin), falling_edge, FALLING); //attach interrupt function
- }
- void loop()
- {
- //empty
- }
- void falling_edge()
- {
- delayMicroseconds(2); //delay 2 microseconds
- PIND&(1<<dataPin)? //if you read a high on Pin 4
- PORTD|=(1<<outPin): //set pin 6 high
- PORTD&=~(1<<outPin); //otherwise set pin 6 low
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement