# Help with twitter node and servo

**URL:** <https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450>\
**Category:** General\
**Created:** [18 August 2019 13:35 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450 "2019-08-18T13:35:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yzerman](https://avatars.discourse-cdn.com/v4/letter/y/ce7236/32.png) [@yzerman](https://discourse.nodered.org/u/yzerman)\
**Post date:** [18 August 2019 13:35 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/1 "2019-08-18T13:35:53Z")

</div>

Hello, i have a problem with flow that controls servo motor via twitter node.  
When i receive tweet with given keyword the servo should go at 120 waits 5s. and goes to 0.  
The problem is that i receive error in my debug node and servo doesn't move. The servo is attached to gpio 17 of raspberry pi.  
 ![Screenshot_](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1edf4386be35607e38db361d5f5db59b74ef1e8b.png)

this is the flow:

```auto

[{"id":"5d6934db.e0f25c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"be759770.bc8b18","type":"twitter in","z":"5d6934db.e0f25c","twitter":"","tags":"testdog11","user":"false","name":"","inputs":0,"x":220,"y":100,"wires":[["f1915a17.e572f8"]]},{"id":"8ee7f69c.772ce8","type":"debug","z":"5d6934db.e0f25c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":60,"wires":[]},{"id":"f1915a17.e572f8","type":"change","z":"5d6934db.e0f25c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"120","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":80,"wires":[["8ee7f69c.772ce8","bb385c43.b5cc3","c13e326d.d8ac5"]]},{"id":"bb385c43.b5cc3","type":"rpi-gpio out","z":"5d6934db.e0f25c","name":"Servo pin","pin":"3","set":"","level":"0","freq":"","out":"pwm","x":720,"y":140,"wires":[]},{"id":"c13e326d.d8ac5","type":"delay","z":"5d6934db.e0f25c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":180,"wires":[["76814639.6c7e38"]]},{"id":"76814639.6c7e38","type":"change","z":"5d6934db.e0f25c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":260,"wires":[["2e668e3d.bd0982","bb867fa0.c9a04"]]},{"id":"2e668e3d.bd0982","type":"debug","z":"5d6934db.e0f25c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":320,"wires":[]},{"id":"bb867fa0.c9a04","type":"rpi-gpio out","z":"5d6934db.e0f25c","name":"Servo pin","pin":"11","set":"","level":"0","freq":"","out":"out","x":860,"y":200,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 August 2019 14:10 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/2 "2019-08-18T14:10:24Z")

</div>

If you read the Info tab for the output node it says that, in digital mode it must only be given 0 or 1. Since you say you are driving a servo I guess that you want PWM mode, but the info tab says that for that mode it must be in the range 0 to 100, or for a servo it should be in the range 10 to 20. You are sending it a value of 120.

**[Edit]** It also says that for PWM you are best to use GPIO02 as it has hardware PWM capability.

**[More Edits]** I am confused, you appear to be driving two different pins, I think you need to explain again what you are trying to do.

---

<div class="post-metadata">

**Author:** ![yzerman](https://avatars.discourse-cdn.com/v4/letter/y/ce7236/32.png) [@yzerman](https://discourse.nodered.org/u/yzerman)\
**Post date:** [18 August 2019 14:35 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/3 "2019-08-18T14:35:59Z")

</div>

Thank you for your answer. The servo is connected to gpio 17. I use two pwm nodes because i need to turn servo at 100 for example, and after 5 seconds i need the servo to turn to 0.  
2 pwm nodes are for gpio 17, so i drive one pin. So as your suggestion i should change the values in my change nodes to something between 10 and 20

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 August 2019 14:51 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/4 "2019-08-18T14:51:16Z")

</div>

You can only have one GPIO node for each pin. You have two nodes, and they are connected to different pins. If you are only driving one actual pin on the device then you must have just one GPIO node. You can connect more than one wire to the same node. If you want to set it to one value then to another after a time then you probably should be using the Trigger node which is designed for exactly that purpose.

---

<div class="post-metadata">

**Author:** ![yzerman](https://avatars.discourse-cdn.com/v4/letter/y/ce7236/32.png) [@yzerman](https://discourse.nodered.org/u/yzerman)\
**Post date:** [18 August 2019 14:59 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/5 "2019-08-18T14:59:09Z")

</div>

I found that trigger node. Thank you very much Colin

---

<div class="post-metadata">

**Author:** ![yzerman](https://avatars.discourse-cdn.com/v4/letter/y/ce7236/32.png) [@yzerman](https://discourse.nodered.org/u/yzerman)\
**Post date:** [18 August 2019 17:19 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/6 "2019-08-18T17:19:32Z")

</div>

Everything works fine with the trigger node - the servo turns to 180 and goes back, but the only problem is that the servo doesn't stop

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 August 2019 19:20 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/7 "2019-08-18T19:20:45Z")

</div>

What do you mean it doesn't stop? Do you mean it goes past where you want it?  
If so then what value are you sending to the GPIO node?

---

<div class="post-metadata">

**Author:** ![yzerman](https://avatars.discourse-cdn.com/v4/letter/y/ce7236/32.png) [@yzerman](https://discourse.nodered.org/u/yzerman)\
**Post date:** [18 August 2019 19:28 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/8 "2019-08-18T19:28:29Z")

</div>

I have continuous rotation servo. My goal is when the tweet appears to turn the servo to 120 degree than after 5 sec to turn back servo to 90 and after that the servo must stop, but in my case the servo continue to spin endlessly. This is my flow:

```auto
[{"id":"5d6934db.e0f25c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"be759770.bc8b18","type":"twitter in","z":"5d6934db.e0f25c","twitter":"","tags":"testdog13","user":"false","name":"","inputs":0,"x":220,"y":100,"wires":[["f1915a17.e572f8"]]},{"id":"8ee7f69c.772ce8","type":"debug","z":"5d6934db.e0f25c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":40,"wires":[]},{"id":"f1915a17.e572f8","type":"change","z":"5d6934db.e0f25c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":100,"wires":[["b818cba3.c03508"]]},{"id":"bb385c43.b5cc3","type":"rpi-gpio out","z":"5d6934db.e0f25c","name":"Servo pin","pin":"11","set":"","level":"0","freq":"","out":"pwm","x":860,"y":160,"wires":[]},{"id":"b818cba3.c03508","type":"trigger","z":"5d6934db.e0f25c","op1":"11","op2":"19","op1type":"num","op2type":"num","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":640,"y":100,"wires":[["8ee7f69c.772ce8","bb385c43.b5cc3"]]}]

```

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [18 August 2019 20:07 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/9 "2019-08-18T20:07:14Z")

</div>

> [@yzerman](#):
>
> I have continuous rotation servo.

Continuous servos are servos that are modified to turn all the time - they cannot be set to turn to an angle and hold that angle I'm afraid ☹

---

<div class="post-metadata">

**Author:** ![yzerman](https://avatars.discourse-cdn.com/v4/letter/y/ce7236/32.png) [@yzerman](https://discourse.nodered.org/u/yzerman)\
**Post date:** [19 August 2019 09:03 UTC](https://discourse.nodered.org/t/help-with-twitter-node-and-servo/14450/10 "2019-08-19T09:03:52Z")

</div>

I figured out that installing gpiod node. Thank you very much for all replays!
