PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

45 lines
1010B

  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. }