# Simple servo sketch killed two Photons

**URL:** <https://community.particle.io/t/simple-servo-sketch-killed-two-photons/39641>\
**Category:** Troubleshooting\
**Created:** [February 18, 2018, 3:16am UTC](https://community.particle.io/t/simple-servo-sketch-killed-two-photons/39641 "2018-02-18T03:16:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickhough](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nickhough/32/16729_2.png) [@nickhough](https://community.particle.io/u/nickhough)\
**Post date:** [February 18, 2018, 3:16am UTC](https://community.particle.io/t/simple-servo-sketch-killed-two-photons/39641/1 "2018-02-18T03:16:11Z")

</div>

I have a sketch I’m running to toggle this [servo](https://www.amazon.com/gp/product/B073M8QT1S/ref=oh_aui_detailpage_o06_s00?ie=UTF8&psc=1) from one position to another.

```
Servo coopDoor;
bool coopOpen;

void setup()
{
   Particle.function("toggleDoor", toggleDoor);

   coopDoor.attach(D0);
   coopDoor.write(0);
   coopOpen = false;
   pinMode(D7, OUTPUT);
}

int toggleDoor(String command)
{
  if (coopOpen) {
    closeDoor();
  } else {
    openDoor();
  }
}

void openDoor()
{
  coopDoor.write(90);
  coopOpen = true;
  delay(500);
}

void closeDoor()
{
  coopDoor.write(0);
  coopOpen = false;
  delay(500);
}

void loop(){}

```

One of the Photons doesn’t even light up when plugged in and the second has a constant white light. Both are getting **very** hot directly above the Setup button.

![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/8/2/82f00125271f9b38ec700c0a2c9e6bb62ef9501f.png)

I’m assuming both these boards are ruined. Any advice on what to change, so I don’t ruin additional boards?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [February 18, 2018, 3:35am UTC](https://community.particle.io/t/simple-servo-sketch-killed-two-photons/39641/2 "2018-02-18T03:35:22Z")

</div>

Hi @nickhough

That area of the Photon is where the voltage regulator is located. Some folks have blown that and then successfully replaced it, but you would have to have a hot-air rework station in my experience.

How are you powering that ginormous servo and the Photon? I suspect very strongly that you are drawing too much current through the Photon board and that has done the damage.

---

<div class="post-metadata">

**Author:** ![nickhough](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nickhough/32/16729_2.png) [@nickhough](https://community.particle.io/u/nickhough)\
**Post date:** [February 18, 2018, 3:47am UTC](https://community.particle.io/t/simple-servo-sketch-killed-two-photons/39641/3 "2018-02-18T03:47:30Z")

</div>

Hi @bko -

Thanks for the prompt response. I have it wired up per one of the Particle [examples](https://docs.particle.io/tutorials/projects/maker-kit/#tutorial-1-servo-gong):

 ![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/1/3/1352131ac6b1bb6ec5e6aedc9dbb04928703ee94.jpg)

I’ll order some new Photons, as I don’t have faith in my abilities to replace those components. I’ll do some searching for an example that powers the servo separate from the Photon.

Thanks for the info!

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [February 18, 2018, 9:16am UTC](https://community.particle.io/t/simple-servo-sketch-killed-two-photons/39641/4 "2018-02-18T09:16:39Z")

</div>

As @bko suggested, wiring the servo like this (and assuming - since not shown) that you are powering the setup through USB the stress on the regulator and/or protection diode was too much.

The regulator does also not like a noisy supply voltage (could be caused by the servo too). The noise might cause the regulator to oscillate and drive it into suicide.

> [@nickhough](#):
>
> I’ll do some searching for an example that powers the servo separate from the Photon.

For that you need to make sure to have common ground for servo and Photon.  
But when you supply power to both (servo _and_ Photon) through Vin and also add some filtering and buffering caps on the supply lines you should be good.

---

<div class="post-metadata">

**Author:** ![nickhough](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nickhough/32/16729_2.png) [@nickhough](https://community.particle.io/u/nickhough)\
**Post date:** [February 18, 2018, 1:57pm UTC](https://community.particle.io/t/simple-servo-sketch-killed-two-photons/39641/5 "2018-02-18T13:57:04Z")

</div>

Hi @ScruffR -

Thanks for the advice. I found [this post](https://community.particle.io/t/noob-question-increase-voltage-high-torque-servo-worth-it/24264/14) and was able to get it working with a Spark Core. Time to get another stash of Photons. 🙂

I wired it as shown below, with the exception of putting the cap across the power/ground strip, as recommended by @peekay123 in the post referenced above.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/2/0/2044085de227c5dc433c21b4ef768cc3def41253.jpg)

Thanks again for the help fellas, much appreciated!
