analogWrite() for SG90

IF SG 90 for Position 0 (1.5 ms pulse) is middle, 90( 2ms pulse) is all the way to the right, -90 ( 1ms pulse) is all the way to the left.”Let’s pretend analogRead() did have a 50Hz PWM frequency (it’s actually 490Hzor 980Hz by default).
What values would I want to write via "analogWrite()" to command the servo to move to positions -90, 0, and 90?

They are two different things. The analogWrite() generates a PWM signal to dim a led or to control the speed of a motor.
A servo motor requires specific pulses, sometimes it is called a PWM signal, but let's call it a "servo signal".

Arduino has a Servo library: Servo - Arduino Reference.
Scroll down for the examples and see in the examples how it is used.

Even at 50Hz, an eight bit PWM signal would not provide sufficient resolution to usefully control an RC servo.

If you do the arithmetic, the shortest RC pulse represents around a 5% duty cycle, and the longest 10%, so the full travel of the servo would be covered by the range 13 to 25.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.