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.

FlashLed.pde 1010B

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. FlexiTimer2:
  3. Arduino library to use timer 2 with a configurable resolution.
  4. Based on MsTimer2 by Javier Valencia. It is called FlexiTimer2 because it
  5. is based on MsTimer2, but offers more flexibility,
  6. since it has a configurable timer resolution.
  7. MsTimer2 library: http://www.arduino.cc/playground/Main/MsTimer2
  8. For more details on FlexiTimer2 see:
  9. http://www.arduino.cc/playground/Main/FlexiTimer2
  10. https://github.com/wimleers/flexitimer2
  11. */
  12. #include <FlexiTimer2.h>
  13. // Switch on LED on and off each half second
  14. #if ARDUINO >= 100
  15. const int led_pin = LED_BUILTIN; // 1.0 built in LED pin var
  16. #else
  17. const int led_pin = 13; // default to pin 13
  18. #endif
  19. void flash()
  20. {
  21. static boolean output = HIGH;
  22. digitalWrite(led_pin, output);
  23. output = !output;
  24. }
  25. void setup()
  26. {
  27. pinMode(led_pin, OUTPUT);
  28. FlexiTimer2::set(500, 1.0/1000, flash); // call every 500 1ms "ticks"
  29. // FlexiTimer2::set(500, flash); // MsTimer2 style is also supported
  30. FlexiTimer2::start();
  31. }
  32. void loop()
  33. {
  34. }