# Using a dashboard switch node to activate motor/step counter

**URL:** https://discourse.nodered.org/t/using-a-dashboard-switch-node-to-activate-motor-step-counter/96261
**Category:** General
**Tags:** node-red-dashboard
**Created:** [26 March 2025 00:22 UTC](https://discourse.nodered.org/t/using-a-dashboard-switch-node-to-activate-motor-step-counter/96261 "2025-03-26T00:22:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RGGabe](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@RGGabe](https://discourse.nodered.org/u/RGGabe)
#### Post date: [26 March 2025 00:22 UTC](https://discourse.nodered.org/t/using-a-dashboard-switch-node-to-activate-motor-step-counter/96261/1 "2025-03-26T00:22:59Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5aeee7d2dee0a8c6c40c99da09c28f7e91d695c1.png)

I am trying to use a switch node on the dashboard and turn my stepper motor on and off. When I do implement a switch node, it sends through a boolean instead of the diameter value which is needed to determine the direction of the motor when it moves. I also want this switch to activate the counter so that both the motor and step counter activate simultaneously. How do I do this while maintaining the diameter value read from the serial port?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [26 March 2025 09:55 UTC](https://discourse.nodered.org/t/using-a-dashboard-switch-node-to-activate-motor-step-counter/96261/2 "2025-03-26T09:55:41Z")

</div>

@RGGabe welcome to the forum!

1. what version of NR are you using?
2. When you say 'dashboard' I think you are referring to the flow editor...correct?
3. add a debug node (set to display the complete map object) to the output of the `MoveMoterCode` function node and run a test. Copy the output and put it in a reply.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path/value for any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

1. Also export your flow and paste it in a response so people can see what you are doing.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [26 March 2025 10:25 UTC](https://discourse.nodered.org/t/using-a-dashboard-switch-node-to-activate-motor-step-counter/96261/3 "2025-03-26T10:25:40Z")

</div>

I suspect you need to _interrupt signals being sent to your stepper_ when your dashboard toggle switch is "off" right?

Use Context to set a flag that you can then use to enable/disable messages passing to the stepper.

e.g.

#### flow 1

`toggle` --\> `change` node (set `flow.enable`)

#### flow 2

data --\> `switch` (is `flow.enable` true?) --\> stepper nodes

* * *

### Context

> **[Working with context : Node-RED](https://nodered.org/docs/user-guide/context)**

### Beginner help

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [24 June 2025 10:26 UTC](https://discourse.nodered.org/t/using-a-dashboard-switch-node-to-activate-motor-step-counter/96261/4 "2025-06-24T10:26:31Z")

</div>

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