Skip to content

Instantly share code, notes, and snippets.

@firatpayalan
Created October 18, 2017 21:05
Show Gist options
  • Save firatpayalan/bc94b4aa1e6ef1b9a3f6c10f7cdd2ab3 to your computer and use it in GitHub Desktop.
Save firatpayalan/bc94b4aa1e6ef1b9a3f6c10f7cdd2ab3 to your computer and use it in GitHub Desktop.
initializes sg90 9g micro servo motor on arduino device.
#include<Servo.h>
Servo servo;
int pos = 0;
int CLOSED_POSITION = 90;
int OPEN_POSITION = 0;
int MILISECOND = 1000;
void setup() {
servo.attach(0);
}
void loop() {
servo.write(CLOSED_POSITION);
delay(MILISECOND*5); //PULSE PERIOD
servo.write(OPEN_POSITION);
delay(1000); // HOLD PERIOD
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment