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.

41 lines
911B

  1. /*
  2. This sketch sweeps a servo on channel 0.
  3. To connect a servo:
  4. 1. Put a 2k-5k pull-up resistor (R0 below; I've tried with 3.3k) between the
  5. servo control output pin and +5v.
  6. 2. Connect that same pin to the servo's control line like so
  7. servo data pin
  8. | _____
  9. OUTn ----+----[_____]---+5v
  10. R0
  11. Steve Pomeroy <steve ~AT~ staticfree.info>, 2009-01-20 */
  12. #include "Tlc5940.h"
  13. #include "tlc_servos.h"
  14. #define SERVO_CHANNEL 0
  15. #define DELAY_TIME 20
  16. void setup()
  17. {
  18. tlc_initServos(); // Note: this will drop the PWM freqency down to 50Hz.
  19. }
  20. void loop()
  21. {
  22. for (int angle = 0; angle < 180; angle++) {
  23. tlc_setServo(SERVO_CHANNEL, angle);
  24. Tlc.update();
  25. delay(DELAY_TIME);
  26. }
  27. for (int angle = 180; angle >= 0; angle--) {
  28. tlc_setServo(SERVO_CHANNEL, angle);
  29. Tlc.update();
  30. delay(DELAY_TIME);
  31. }
  32. }