Skip to content

Instantly share code, notes, and snippets.

@Soreil
Created February 27, 2017 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Soreil/ee25ff440cdd4b5acf1e5bcff5c8d972 to your computer and use it in GitHub Desktop.
Save Soreil/ee25ff440cdd4b5acf1e5bcff5c8d972 to your computer and use it in GitHub Desktop.
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