-
-
Save sankarcheppali/10ee875116e6ee7c0de3f82ab80de1e6 to your computer and use it in GitHub Desktop.
Arduino servo sweep program for ESP32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Arduino.h" | |
#include <Servo.h> | |
#define SERVO_SIGNAL_PIN 12 | |
Servo serialServo; | |
void setup() | |
{ | |
Serial.begin(115200); | |
Serial.println("Sweep Servo"); | |
serialServo.attach(SERVO_SIGNAL_PIN); | |
} | |
void setServoAngle(int angle){ | |
serialServo.write(angle); | |
} | |
void sweep(){ | |
for (int angle = 0; angle <= 180; angle++) { | |
setServoAngle(angle); | |
delay(8); | |
} | |
for (int angle = 180; angle >= 0; angle--) { | |
setServoAngle(angle); | |
delay(8); | |
} | |
} | |
void loop() | |
{ | |
sweep(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment