# Control robot arm with on / off button

**URL:** <https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213>\
**Category:** General\
**Created:** [21 November 2019 01:54 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213 "2019-11-21T01:54:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suave](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@Suave](https://discourse.nodered.org/u/Suave)\
**Post date:** [21 November 2019 01:54 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213/1 "2019-11-21T01:54:29Z")

</div>

I have a robot arm with 4 servos and I want to use an on / off button to start a process. I found several examples of flows where they use a slide bar to individually control each servo. My question is can I use a button to start the process until I turn off that button?

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [21 November 2019 03:52 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213/2 "2019-11-21T03:52:59Z")

</div>

How does the robot talk to the NR controller ?

Create a dashboard page, insert a Button, have it send a command on a MQTT topic.

In your Flow - monitor that topic and then send out the commands to the 4 servos on other MQTT topics

Have a 2nd button on the dashboard that does the opposite to stop the robot

This all assume of course that your robot is able to be spoken to by MQTT

---

<div class="post-metadata">

**Author:** ![Suave](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@Suave](https://discourse.nodered.org/u/Suave)\
**Post date:** [22 November 2019 03:00 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213/3 "2019-11-22T03:00:42Z")

</div>

Thanks I will try that.  
I am using an Esp8266, MQTT and Node-RED.  
Another question, I have to put an MQTT theme for each servo even if it is a single process but that includes each servo separately?

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [25 November 2019 02:39 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213/4 "2019-11-25T02:39:23Z")

</div>

No you could have a single MQTT topic and have your code on the ESP8266 turn off/on all the servos at one depending on what you receive

Are you writing your own code for the ESP8266 or using one of the prebuilt firmwares ?

Depending on what level of PMW/Stepping you are trying to do on the ESP8266 i do not think you will be able to control 4 servos

It may be worthwhile looking at a dedicated servo controller/board that connects to the ESP8266

Craig

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 November 2019 07:16 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213/5 "2019-11-25T07:16:45Z")

</div>

I've used this servo controller board with a Wemos D1 Mini (ESP8266) flashed with ESP-Easy.

> **[US $3.29 |2PCS PCA9685 16 Channel 16CH 12 bit PWM Servo Motor Driver I2C...](https://www.aliexpress.com/item/32995944323.html?spm=a2g0o.productlist.0.0.2f7372cetEkZkM&algo_pvid=5d1abc6c-df19-49ab-a269-2c6c3ec7baa5&algo_expid=5d1abc6c-df19-49ab-a269-2c6c3ec7baa5-3&btsid=bb83f64b-565e-4932-9f2c-92f3e5f595b4&ws_ab_test=searchweb0_0%2Csearchweb201602_9%2Csearchweb201603_55)**
>
> Smarter Shopping, Better Living! Aliexpress.com

The basic PWM function (using ESP Easy) is limited to controlling two servos, so this external board gets over that limitation. There are drivers on the 'Devices' tab (within ESP-Easy) so implementation should be simple.

---

<div class="post-metadata">

**Author:** ![Suave](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@Suave](https://discourse.nodered.org/u/Suave)\
**Post date:** [25 November 2019 21:01 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213/6 "2019-11-25T21:01:34Z")

</div>

The arduino code I am doing based on some examples but using the slider and the original code of MQTT\_esp8266, what I am trying to do is that when the switch button receives a 1 it starts the process of the robot arm and when it is a 0 it stops.

I decided to do it this way because I could do it with Blynk, but this is just the beginning of my programming, then I went to add sensors and other motors, and the blynk no longer supported me for that.

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [25 November 2019 23:04 UTC](https://discourse.nodered.org/t/control-robot-arm-with-on-off-button/18213/7 "2019-11-25T23:04:02Z")

</div>

As Dave has said above - go to a precompiled image (EspEasy) and use the board above (presuming that it is adequate for the servos you are driving)

Craig
