Advertisement
Guest User

Untitled

a guest
Dec 27th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. /*
  2. * Timer1 library example
  3. */
  4.  
  5. #include "TimerOne.h"
  6.  
  7. void setup()
  8. {
  9. pinMode(10, OUTPUT);
  10. Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period
  11. Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle
  12. Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
  13. }
  14.  
  15. void callback()
  16. {
  17. digitalWrite(10, digitalRead(10) ^ 1);
  18. }
  19.  
  20. void loop()
  21. {
  22. // your program here...
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement