mcopy/ino/components/mcopy_servo_debug/mcopy_servo_debug.ino

40 lines
689 B
Arduino
Raw Normal View History

2022-07-06 18:42:16 +00:00
#include <Servo.h>
2022-07-17 13:56:03 +00:00
const int PIN_SERVO = 6;
2022-07-06 18:42:16 +00:00
Servo servo;
/*
----------------------------------------------------
Servo - Arduino
-
Red - 5V
Black - GND
Yellow - PWM Pin (9 in this example)
Using TowerPro SG-5010 - default 93
TowerPro MG-995 -
as servos for development
----------------------------------------------------
*/
void setup() {
Serial.begin(57600);
Serial.flush();
Servo_init();
}
void loop() {
2022-07-17 13:56:03 +00:00
delay(1000);
servo.write(153);
delay(1000);
servo.write(93);
2022-07-06 18:42:16 +00:00
}
void Servo_init () {
servo.attach(PIN_SERVO);
int angle = servo.read();
Serial.print("Default angle: ");
Serial.println(angle);
}