@@ -385,112 +385,7 @@ void loop()
385385
386386#### 1. File [ ESP32_C3_ISR_MultiServos.ino] ( examples/ESP32_C3_ISR_MultiServos/ESP32_C3_ISR_MultiServos.ino )
387387
388- ``` cpp
389- #if !defined( ARDUINO_ESP32C3_DEV )
390- #error This code is intended to run on the ESP32_C3 platform! Please check your Tools->Board setting.
391- #endif
392-
393- #define TIMER_INTERRUPT_DEBUG 0
394- #define ISR_SERVO_DEBUG 1
395-
396- // Select different ESP32 timer number (0-1) to avoid conflict
397- #define USE_ESP32_TIMER_NO 1
398-
399- #include " ESP32_C3_ISR_Servo.h"
400-
401- // See file .../hardware/espressif/esp32/variants/(esp32|doitESP32devkitV1)/pins_arduino.h
402- #define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
403- #define PIN_LED 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
404-
405- #define PIN_D0 0 // Pin D0 mapped to pin GPIO0/BOOT/ADC11/TOUCH1 of ESP32
406- #define PIN_D1 1 // Pin D1 mapped to pin GPIO1/TX0 of ESP32
407- #define PIN_D2 2 // Pin D2 mapped to pin GPIO2/ADC12/TOUCH2 of ESP32
408- #define PIN_D3 3 // Pin D3 mapped to pin GPIO3/RX0 of ESP32
409- #define PIN_D4 4 // Pin D4 mapped to pin GPIO4/ADC10/TOUCH0 of ESP32
410- #define PIN_D5 5 // Pin D5 mapped to pin GPIO5/SPISS/VSPI_SS of ESP32
411- #define PIN_D6 6 // Pin D6 mapped to pin GPIO6/FLASH_SCK of ESP32
412- #define PIN_D7 7 // Pin D7 mapped to pin GPIO7/FLASH_D0 of ESP32
413- #define PIN_D8 8 // Pin D8 mapped to pin GPIO8/FLASH_D1 of ESP32
414- #define PIN_D9 9 // Pin D9 mapped to pin GPIO9/FLASH_D2 of ESP32
415-
416- // Published values for SG90 servos; adjust if needed
417- #define MIN_MICROS 800 //544
418- #define MAX_MICROS 2450
419-
420- int servoIndex1 = -1 ;
421- int servoIndex2 = -1 ;
422-
423- void setup ()
424- {
425- Serial.begin(115200);
426- while (!Serial);
427-
428- delay (500);
429-
430- Serial.print(F("\nStarting ESP32_C3_ISR_MultiServos on ")); Serial.println(ARDUINO_BOARD);
431- Serial.println(ESP32_C3_ISR_SERVO_VERSION);
432-
433- //Select ESP32 timer USE_ESP32_TIMER_NO
434- ESP32_ISR_Servos.useTimer(USE_ESP32_TIMER_NO);
435-
436- servoIndex1 = ESP32_ISR_Servos.setupServo(PIN_D3, MIN_MICROS, MAX_MICROS);
437- servoIndex2 = ESP32_ISR_Servos.setupServo(PIN_D4, MIN_MICROS, MAX_MICROS);
438-
439- if (servoIndex1 != -1)
440- Serial.println(F("Setup Servo1 OK"));
441- else
442- Serial.println(F("Setup Servo1 failed"));
443-
444- if (servoIndex2 != -1)
445- Serial.println(F("Setup Servo2 OK"));
446- else
447- Serial.println(F("Setup Servo2 failed"));
448- }
449-
450- void loop ()
451- {
452- int position;
453-
454- if ( ( servoIndex1 != -1) && ( servoIndex2 != -1) )
455- {
456- for (position = 0; position <= 180; position++)
457- {
458- // goes from 0 degrees to 180 degrees
459- // in steps of 1 degree
460-
461- if (position % 30 == 0)
462- {
463- Serial.print(F("Servo1 pos = ")); Serial.print(position);
464- Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
465- }
466-
467- ESP32_ISR_Servos.setPosition(servoIndex1, position);
468- ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
469- // waits 30ms for the servo to reach the position
470- delay (30);
471- }
472-
473- delay (5000);
474-
475- for (position = 180; position >= 0; position--)
476- {
477- // goes from 180 degrees to 0 degrees
478- if (position % 30 == 0)
479- {
480- Serial.print(F("Servo1 pos = ")); Serial.print(position);
481- Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
482- }
483-
484- ESP32_ISR_Servos.setPosition(servoIndex1, position);
485- ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
486- // waits 30ms for the servo to reach the position
487- delay (30);
488- }
489-
490- delay (5000);
491- }
492- }
493- ```
388+ https://github.com/khoih-prog/ESP32_C3_ISR_Servo/blob/f6a14a464742a98edda265ce332289a3a9b363eb/examples/ESP32_C3_ISR_MultiServos/ESP32_C3_ISR_MultiServos.ino#L72-L184
494389
495390---
496391---
0 commit comments