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?
@RGGabe welcome to the forum!
- what version of NR are you using?
- When you say 'dashboard' I think you are referring to the flow editor...correct?
- 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) 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.
- 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 ```
)
```
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
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
Beginner help
I recommend watching this playlist: Node-RED Essentials. 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.