# SG90 don't work

**URL:** <https://forum.arduino.cc/t/sg90-dont-work/1331585>\
**Category:** Motors, Mechanics, Power and CNC\
**Created:** [December 12, 2024, 1:36pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585 "2024-12-12T13:36:00Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![thunder200911133](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/thunder200911133/32/1128147_2.png) [@thunder200911133](https://forum.arduino.cc/u/thunder200911133)\
**Post date:** [December 12, 2024, 1:36pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/1 "2024-12-12T13:36:00Z")

</div>

I was trying to make my servo motor move 90 degree each time I put my hand near the ultrasonic sensor, and wait 5 sec, turn back to 0 degree. And I've tested that my sensor works. The only thing that's weird is that, my servo motor keep turning even when the ultrasonic reading is large, and stop when the value is small. I don't know what happen.

```arduino
#include<Servo.h>

int trig = 3;
int echo = 2;

double cm;
int dur;

Servo myservo;

void setup()
{
  Serial.begin(9600);
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  myservo.attach(4);
  myservo.write(0);
}

void loop()
{
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  
  dur = pulseIn(echo, HIGH);
  
  cm = dur * 0.034 / 2;
  
  if (cm <= 100){
    myservo.write(90);
    delay(5000);
    myservo.write(0);
  }
  
  Serial.println(cm);
  delay(200);
}

```

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [December 12, 2024, 1:49pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/2 "2024-12-12T13:49:04Z")

</div>

What does your circuit / power look like?

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [December 12, 2024, 1:50pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/3 "2024-12-12T13:50:44Z")

</div>

> [@thunder200911133](#):
>
> my servo motor keep turning

Do you mean that it rotates through 360 degrees and keeps going ?

If so then you do not have a servo

---

<div class="post-metadata">

**Author:** ![hallowed31](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hallowed31/32/1093680_2.png) [@hallowed31](https://forum.arduino.cc/u/hallowed31)\
**Post date:** [December 12, 2024, 1:57pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/4 "2024-12-12T13:57:13Z")

</div>

> [@UKHeliBob](#):
>
> Do you mean that it rotates through 360 degrees and keeps going ?
> 
> If so then you do not have a servo

I have seen this with the SG90. Specifically, the one that came with the Elegoo Arduino Starter Kit. I was abusing an Uno R3 by powering the servo with the Uno +5V pin, and it rotated through 360 degrees multiple times until I cut the power.

I then ran the same code on the same servo on the same Uno, powering the servo at 5V with my bench power supply, and it worked normally again.

Can't speak to why this was the case, but for me, this was the case.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [December 12, 2024, 3:47pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/5 "2024-12-12T15:47:57Z")

</div>

> [@hallowed31](#):
>
> Can't speak to why this was the case

Maybe there are no hard end stops in those cheap servos.

This problem has come up a lot in the forum, lately, and it is often the case that people are following the terrible advice to power the servo from the 5V pin.

---

<div class="post-metadata">

**Author:** ![thunder200911133](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/thunder200911133/32/1128147_2.png) [@thunder200911133](https://forum.arduino.cc/u/thunder200911133)\
**Post date:** [December 12, 2024, 4:18pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/6 "2024-12-12T16:18:21Z")

</div>

What is bench supply power?  
And I think I have an arduino mega. And yes, I think we have the same servo motor.

---

<div class="post-metadata">

**Author:** ![thunder200911133](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/thunder200911133/32/1128147_2.png) [@thunder200911133](https://forum.arduino.cc/u/thunder200911133)\
**Post date:** [December 12, 2024, 4:19pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/7 "2024-12-12T16:19:21Z")

</div>

It says it's a micro servo

It's this:

 ![61yfIwAxe0L.SL1421](https://europe1.discourse-cdn.com/arduino/original/4X/c/a/c/cacf63ee6468cea2d6ab390767ab3047013dbb27.jpeg)

---

<div class="post-metadata">

**Author:** ![hallowed31](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hallowed31/32/1093680_2.png) [@hallowed31](https://forum.arduino.cc/u/hallowed31)\
**Post date:** [December 12, 2024, 4:20pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/8 "2024-12-12T16:20:44Z")

</div>

> [@anon94801460](#):
>
> Maybe there are no hard end stops in those cheap servos.

Maybe, I couldn't say. I just tried rotating the shaft on mine, two full rotations counter clockwise before it stopped; six full rotations clockwise and it still freely turned. Then went to go back again and heard a little plastic snap like it was forced past a stop. I wasn't applying much torque at all.

Maybe just really cjeap or undersized, worn down, I don't know.

---

<div class="post-metadata">

**Author:** ![hallowed31](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hallowed31/32/1093680_2.png) [@hallowed31](https://forum.arduino.cc/u/hallowed31)\
**Post date:** [December 12, 2024, 4:27pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/9 "2024-12-12T16:27:03Z")

</div>

> [@thunder200911133](#):
>
> What is bench supply power?

A PC PSU that was converted into a convenient DC supply for electronics prototyping and testing. It's an extremely popular way to get a 3.3V, 5V and 12V power supply capable of allowing higher current devices to be powered off it.

If you don't have one and are getting more into electronics, it's essential. It's also very easy to make one. Tons of tutorials online.

Yes, you can purchase commercially available bench power supplies; however, it seems to me that making your own is almost a rite of passage for the novice electronics hobbyist.

> [@thunder200911133](#):
>
> And I think I have an arduino mega. And yes, I think we have the same servo motor.

Mega and Uno R3 have the same 5V regulator for all intent and purpose, ie, not suitable for powering servos. My SG90 is a generic type of yours, not specifically Tower Pro brand.

---

<div class="post-metadata">

**Author:** ![thunder200911133](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/thunder200911133/32/1128147_2.png) [@thunder200911133](https://forum.arduino.cc/u/thunder200911133)\
**Post date:** [December 12, 2024, 4:35pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/11 "2024-12-12T16:35:47Z")

</div>

I don't think my school have these...

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [December 12, 2024, 5:31pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/12 "2024-12-12T17:31:15Z")

</div>

Please post a link to where you got it from

---

<div class="post-metadata">

**Author:** ![thunder200911133](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/thunder200911133/32/1128147_2.png) [@thunder200911133](https://forum.arduino.cc/u/thunder200911133)\
**Post date:** [December 12, 2024, 5:45pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/13 "2024-12-12T17:45:53Z")

</div>

School teacher  
However, I do know it's the exact same brand, label, sticker

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [December 12, 2024, 5:48pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/14 "2024-12-12T17:48:59Z")

</div>

If you cannot post a link to where you got the servo then please post a 'photo of the actual servo that you have, not one taken from the Web

---

<div class="post-metadata">

**Author:** ![Wawa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wawa/32/1211303_2.png) [@Wawa](https://forum.arduino.cc/u/Wawa)\
**Post date:** [December 12, 2024, 7:54pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/15 "2024-12-12T19:54:32Z")

</div>

Not all (cheap) servos can do the full 180 degrees,  
so if you don't need to swing 180 degrees, don't try to get to 0 or 180.

It seems you only need a swing of 90 degrees.  
In setup() you should have written to 45 degrees, and in loop() 135 degrees. That would also have given you a swing of 90, without getting close to the potentially damaging end stops.  
Leo..

---

<div class="post-metadata">

**Author:** ![thunder200911133](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/thunder200911133/32/1128147_2.png) [@thunder200911133](https://forum.arduino.cc/u/thunder200911133)\
**Post date:** [December 12, 2024, 8:34pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/16 "2024-12-12T20:34:33Z")

</div>

Guys I fixed it.  
It's doesn't work simpy because it's broken.

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [December 12, 2024, 9:01pm UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/17 "2024-12-12T21:01:11Z")

</div>

Would you describe how it is broken, and if you know - how it became broken, so I will know a symptom of "that" problem? Thank you.

---

<div class="post-metadata">

**Author:** ![thunder200911133](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/thunder200911133/32/1128147_2.png) [@thunder200911133](https://forum.arduino.cc/u/thunder200911133)\
**Post date:** [December 13, 2024, 1:02am UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/18 "2024-12-13T01:02:50Z")

</div>

So basically, my micro servo SG90 is only suppose to turn 180 degrees, but it turn full 360. Also, when I use write command in the setup, it's suppose to run it only 1 time. But it keep running for a long time after I upload the code to the board.

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [December 13, 2024, 1:17am UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/19 "2024-12-13T01:17:50Z")

</div>

This topic sounds familiar. (the verdict was inconclusive)

> [@Tower Pro Micro Servo 9g SG90](https://forum.arduino.cc/t/tower-pro-micro-servo-9g-sg90/1311836):
>
> I needed 32 hobby servo motors for a project, so I ordered 25 Tower Pro SG90, since I had a whole bunch of them from a previous project. Now when I go through them and test them, I've found at least two, which are continuous motors (you know, those which always rise arguments about whether they are servos or not). As continuous motors they work well, running in both directions at different speeds depending on the "angle" in the servo command. But the strange thing is that they are labeled exac…

This sketch (in a 180 servo simulation) might work on your servo... if it is a 360 servo, if will slowly increase in speed in a clockwise direction, then decrease speed in a clockwise direction, then repeat the same in the counter-clockwise direction.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 11, 2025, 1:18am UTC](https://forum.arduino.cc/t/sg90-dont-work/1331585/20 "2025-06-11T01:18:10Z")

</div>

Closed on June 11, 2025, 1:18am UTC

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