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.

loopCounter.ino 1.3KB

3 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <Keypad.h>
  2. const byte ROWS = 4; //four rows
  3. const byte COLS = 3; //three columns
  4. char keys[ROWS][COLS] = {
  5. {'1','2','3'},
  6. {'4','5','6'},
  7. {'7','8','9'},
  8. {'*','0','#'}
  9. };
  10. byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
  11. byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
  12. Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
  13. unsigned long loopCount = 0;
  14. unsigned long timer_ms = 0;
  15. void setup(){
  16. Serial.begin(9600);
  17. // Try playing with different debounceTime settings to see how it affects
  18. // the number of times per second your loop will run. The library prevents
  19. // setting it to anything below 1 millisecond.
  20. kpd.setDebounceTime(10); // setDebounceTime(mS)
  21. }
  22. void loop(){
  23. char key = kpd.getKey();
  24. // Report the number of times through the loop in 1 second. This will give
  25. // you a relative idea of just how much the debounceTime has changed the
  26. // speed of your code. If you set a high debounceTime your loopCount will
  27. // look good but your keypresses will start to feel sluggish.
  28. if ((millis() - timer_ms) > 1000) {
  29. Serial.print("Your loop code ran ");
  30. Serial.print(loopCount);
  31. Serial.println(" times over the last second");
  32. loopCount = 0;
  33. timer_ms = millis();
  34. }
  35. loopCount++;
  36. if(key)
  37. Serial.println(key);
  38. }