PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 3 gadiem
12345678910111213141516171819202122232425262728293031323334353637
  1. // Sweep
  2. // by BARRAGAN <http://barraganstudio.com>
  3. // http://arduiniana.org/libraries/pwmservo/
  4. // Board SERVO_PIN_A SERVO_PIN_B SERVO_PIN_C
  5. // ----- ----------- ----------- -----------
  6. // Arduino Uno, Duemilanove 9 10 (none)
  7. // Arduino Mega 11 12 13
  8. // Sanguino 13 12 (none)
  9. // Teensy 1.0 17 18 15
  10. // Teensy 2.0 14 15 4
  11. // Teensy++ 1.0 or 2.0 25 26 27
  12. // Teensy LC & 3.x (all PWM pins are usable)
  13. #include <PWMServo.h>
  14. PWMServo myservo; // create servo object to control a servo
  15. int pos = 0; // variable to store the servo position
  16. void setup() {
  17. myservo.attach(SERVO_PIN_A); // attaches the servo on pin 9 to the servo object
  18. //myservo.attach(SERVO_PIN_A, 1000, 2000); // some motors need min/max setting
  19. }
  20. void loop() {
  21. for(pos = 0; pos < 180; pos += 1) { // goes from 0 degrees to 180 degrees, 1 degree steps
  22. myservo.write(pos); // tell servo to go to position in variable 'pos'
  23. delay(15); // waits 15ms for the servo to reach the position
  24. }
  25. for(pos = 180; pos>=1; pos-=1) { // goes from 180 degrees to 0 degrees
  26. myservo.write(pos); // tell servo to go to position in variable 'pos'
  27. delay(15); // waits 15ms for the servo to reach the position
  28. }
  29. }