Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define dataPin 4
- #define outPin 6
- #define MICROSECOND_NOPS "nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n" //Assembly for 1/6 microsecond using clock pulses
- void setup()
- {
- pinMode(outPin, OUTPUT);
- pinMode(dataPin, INPUT);
- attachInterrupt(digitalPinToInterrupt(dataPin), falling_edge, FALLING); //attach interrupt function
- }
- void loop()
- {
- //empty
- }
- void falling_edge()
- {
- asm volatile( MICROSECOND_NOPS MICROSECOND_NOPS
- MICROSECOND_NOPS MICROSECOND_NOPS
- MICROSECOND_NOPS MICROSECOND_NOPS
- MICROSECOND_NOPS MICROSECOND_NOPS
- MICROSECOND_NOPS MICROSECOND_NOPS
- MICROSECOND_NOPS MICROSECOND_NOPS );
- digitalReadFast(dataPin)?
- digitalWriteFast(outPin, HIGH):
- digitalWriteFast(outPin, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement