Engineer's Asylum

How to run a servo without libraries [PWM fundamentals + Spreadsheet]

Hey members,

It’s official, Engineer’s Asylum is on YouTube now. Check out our channel with HD1080p :iphone: videos (english subtitles available) and keep learning about electronics and embedded systems.

We are very glad to present our first tutorial on a basic analogic project.
Arduino Basics #1:

Components Needed:

  1. Jumping wires
  2. Solid core jumping wires
  3. Analogic servo ( SM-S2309S )
  4. Datasheet
  5. Breadboard
  6. USB cable
  7. Arduino UNO

Project downloads :bulb: :file_folder::

//_____________Basic__PWM__servo__control__________
const int Servo_control_pin = 9;

void setup() {
  Serial.begin(9600);
  pinMode(Servo_control_pin, OUTPUT);
}
void loop() {
  for (int i = 0; i < 50; i++) {
    digitalWrite(Servo_control_pin, HIGH);
    delayMicroseconds(480);
    digitalWrite(Servo_control_pin, LOW);
    delayMicroseconds(19520);
  }//0º
  delay(3000);
  for (int i = 0; i < 50; i++) {
    digitalWrite(Servo_control_pin, HIGH);
    delayMicroseconds(1230);
    digitalWrite(Servo_control_pin, LOW);
    delayMicroseconds(18780);
  }//90º
  delay(3000);
  for (int i = 0; i < 50; i++) {
    digitalWrite(Servo_control_pin, HIGH);
    delayMicroseconds(2091);
    digitalWrite(Servo_control_pin, LOW);
    delayMicroseconds(17909);
  }//180º
  delay(3000);
for (int i = 0; i < 50; i++) {
    digitalWrite(Servo_control_pin, HIGH);
    delayMicroseconds(1693);
    digitalWrite(Servo_control_pin, LOW);
    delayMicroseconds(18301);
  }//135º
  delay(3000);
}
\\---------------------Engineer's Asylum---------------------\\

Subscribe for more content, like and share your thoughts on the comments. Support us :fist: