Created
February 27, 2017 10:28
-
-
Save Soreil/ee25ff440cdd4b5acf1e5bcff5c8d972 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uint8_t wireIn = 14; | |
const uint8_t wireOut = 15; | |
int timer1_counter = 0; | |
int timer = 0; | |
void setup() | |
{ | |
pinMode(wireIn, INPUT); | |
pinMode(wireOut, OUTPUT); | |
noInterrupts(); | |
timer1_counter = 0xffff / 8; | |
TCNT1 = timer1_counter; | |
TCCR1A = 0; | |
TCCR1B |= (1 << CS10); | |
TIMSK1 |= (1 << TOIE1); | |
interrupts(); | |
} | |
ISR(TIMER1_OVF_vect) { | |
TCNT1 = timer1_counter; | |
timer++; | |
digitalWrite(wireOut, timer % 2); | |
} | |
void loop() | |
{ | |
/* add main program code here */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment