PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 line
690B

  1. /*
  2. MsTimer2 is a small and very easy to use library to interface Timer2 with
  3. humans. It's called MsTimer2 because it "hardcodes" a resolution of 1
  4. millisecond on timer2
  5. For Details see: http://www.arduino.cc/playground/Main/MsTimer2
  6. */
  7. #include <MsTimer2.h>
  8. // Switch on LED on and off each half second
  9. #if ARDUINO >= 100
  10. const int led_pin = LED_BUILTIN; // 1.0 built in LED pin var
  11. #else
  12. const int led_pin = 13; // default to pin 13
  13. #endif
  14. void flash()
  15. {
  16. static boolean output = HIGH;
  17. digitalWrite(led_pin, output);
  18. output = !output;
  19. }
  20. void setup()
  21. {
  22. pinMode(led_pin, OUTPUT);
  23. MsTimer2::set(500, flash); // 500ms period
  24. MsTimer2::start();
  25. }
  26. void loop()
  27. {
  28. }