-
Notifications
You must be signed in to change notification settings - Fork 42
CPP: Servo sg90
Leo Vidarte edited this page Mar 8, 2017
·
1 revision
The sg90 servo has three wires: brown (gnd), red (vcc), and yellow (signal). The vcc is the power source for the servo, and it has to be connected to the vin pin of our board – this way it is connected directly to the USB port, and not powered through the board.
Checkout this PlatformIO project code here
#include <Arduino.h>
#include <Servo.h>
Servo servo;
void setup ()
{
servo.attach(14);
}
void loop ()
{
// To 0°
servo.write(0);
delay(1000);
// To 90°
servo.write(90);
delay(1000);
// To 180°
servo.write(180);
delay(1000);
}
ESP8266 NodeMCU Workshop - 2017