Servo Tester Only Using Arduino Nano
by Tommi13 in Circuits > Arduino
815 Views, 2 Favorites, 0 Comments
Servo Tester Only Using Arduino Nano
This is a servo tester using only a arduino nanao and nothing else this is used to sweep a servo from 0 degree to 180 degree
Supplies
3x female to male jumper wire
Hardware Connections
Hardware Connections:
- Connect the servo's GND (Ground) wire to one of the GND pins on the Arduino Nano.
- Connect the servo's V+ (Power) wire to the 5V pin on the Arduino Nano.
- Connect the servo's PWM (Signal) wire to digital pin 10 (D10) on the Arduino Nano.
Code
#include <Servo.h>
Servo servo; // Create a Servo object
int servoPin = 10; // Pin connected to the servo
void setup() {
servo.attach(servoPin); // Attaches the servo to the specified pin
}
void loop() {
// Sweep the servo from 0 to 180 degrees
for (int angle = 0; angle <= 180; angle++) {
servo.write(angle); // Set servo position
delay(15); // Delay for smoother motion, adjust as needed
}
// Sweep the servo from 180 to 0 degrees
for (int angle = 180; angle >= 0; angle--) {
servo.write(angle); // Set servo position
delay(15); // Delay for smoother motion, adjust as needed
}
}