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.

преди 3 години
123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. This code will blink an LED attached to pin 13 on and off.
  3. It will stay on for 0.25 seconds.
  4. It will stay off for 1 second.
  5. */
  6. #include <Metro.h> //Include Metro library
  7. #define LED 13 // Define the led's pin
  8. //Create a variable to hold theled's current state
  9. int state = HIGH;
  10. // Instanciate a metro object and set the interval to 250 milliseconds (0.25 seconds).
  11. Metro ledMetro = Metro(250);
  12. void setup()
  13. {
  14. pinMode(LED,OUTPUT);
  15. digitalWrite(LED,state);
  16. }
  17. void loop()
  18. {
  19. if (ledMetro.check() == 1) { // check if the metro has passed its interval .
  20. if (state==HIGH) {
  21. state=LOW;
  22. ledMetro.interval(250); // if the pin is HIGH, set the interval to 0.25 seconds.
  23. }
  24. else {
  25. ledMetro.interval(1000); // if the pin is LOW, set the interval to 1 second.
  26. state=HIGH;
  27. }
  28. digitalWrite(LED,state);
  29. }
  30. }