I have a clock node looping the code but It seems like those two nodes only output pulse on detecting a change, but not if the value stays the same over subsequent cycles.
What would you suggest to change their behaviour to continuously pulse while their respective value is matching?

I don’t have my computer handy, but I’m pretty sure there is a pulse-continuous node. If it doesn’t have an input to enable/disable, you can use a gate node to block the pulses you don’t want, or use branch node to route them correctly.

It is not always possible, but you might be able to change your code to work with true/false instead of using pulses.

I have deleted “&& state == false” out of the node code and now it seems to work the way I want

If you want continuous readings when a boolean is true, just use an if-else node.

That was my original idea but it didn’t work.
I have a “less” node that outputs boolean and I need to drive a servo motor on “true”.
“If-else” will pulse on either false or true, so, useless

Can you post a screen shot of your project?

Your statement regarding if-else generating a pulse on “either false or true, so, useless” doesn’t quite make sense.
If you only want to do something when you have a true boolean, ‘if-else’ is literally the exact thing you require…
Connect your nodes for servo control to the ‘true’ input of the if-else and then connect the if-else output to the servo device.

You can also have your boolean connect directly to the ‘act’ pin of the servo device.

Somehow “if-else” didn’t work for me.
Removing condition check “&& state == false” out of “pulse-on-true” did the trick however.

Don’t mind the cropped part, it’s a serial output.

The only thing I haven’t figured out yet is how to detach the servo once it’s back to 0

Are you using ‘pulse-on-true’ or ‘pulse-on-change’?

And what do you mean ‘detach’ the servo? As in, power down/stop the jitter?

Also, the way you have your ‘less-than’ setup will give you a true result if your reading is above 0.34.
If you need the servo to operate when the reading is below 0.34, you’ll need to move the 0.34 to ‘IN2’

I’m not sure what you’e doing there after the ‘rotate_back’ command. The whole setup could be simplified to this

It also might be worth having the readings pause for a while to allow moisture levels to equalise (I’m guessing you’re using a servo to tip water into soil?

Dear mci-ryan, thanks for all your suggestions. As I already mentioned my sketch works perfectly well. All the nodes, including less, do exactly what I want them to do and there are delays where required.

Following ‘rotate-back’ I have a counter, there is also a remapper and a long string of concats that feeds UART>print setup some values I am interested in. I cropped that part out because it’s irrelevant.

As I already mentioned the ‘if-else’ way does not work. If you read this node’s description carefully you will see that it Outputs either input value depending on condition.I think it means it will pulse on either true or false, hence, useless. This is exactly the behaviour I observed and that’s why I decided to modify ‘pulse-on-true’ to suit my needs.

By “detach” I mean power servo off. I believe this what the Arduino command is called but I may be wrong.

No need to be condescending.

“If you read the node’s description carefully”… If-else does not pulse on true or false. it is a logic gate. if the condition is true, it allows whatever is linked to ‘true’ to pass through. if the condition is false, it allows whatever is linked to ‘false’ to pass through. if-else does not produce any pulses, it can only open to door for whatever is linked to the T/F inputs.

to turn the servo off, you would need to wire the voltage feed through a pin (or a relay if high current) that is controlled by a digital pin.

I am only trying to explain to you that your suggested patch does not work the way you describe.
Please, wire this up yourself and check if you wish.

And below is the code, by gweimer, that detaches the servo, but this function is absent in the node I am using.

#include <Servo.h>

struct State {
Servo servo;


void evaluate(Context ctx) {
State* state = getState(ctx);
auto port = (int)getValue<input_PORT>(ctx);
auto En = getValue<input_En>(ctx);

if (En) {
    state->servo.write(getValue<input_VAL>(ctx) * 180);
} else {


It does work. that was the point of me showing it to you…
Note: the code excerpt that you’ve posted from the Gweimer/Servo library uses an if-else. Hopefully you can understand the logic of if-else when it isn’t coming from me. You can also use a gate, a pass-if and many other nodes that will accomplish what you’re trying to do. Using a method like this will mean that you don’t need to modify the C++ implementation and therefore it won’t affect the way the node works for other projects.

If you want to use gweimers library, then just use the node you’ve taken the excerpt from… It’ll accomplish the same thing that the xod-dev/servo does, with the detach that you’re after.

Worth noting is that if you detach (stop pwm pulses), the servo will be free to rotate, i.e. no position ‘hold’.

I have assembled the patch with “if-else” again, exactly the way you proposed and the servo was just going back and forth every clock tick, regardless of the “less” node output.

As I said before this was my original patch design and the reason I started this thread.

I have only modified a cloned node within my project so this won’t affect anything else.

The problem is now solved so we can end this discussion.

That’s probably because of the ‘less-than’ that you have set, which is basically running the pulse whenever 0.34 is less than the moisture reading value.

Basically if the moisture reading is 0.35 to max, you’re activating the servo.

If you want to activate when the sensor reading is LESS THAN 0.34 (MIN to 0.34), you need to move the input to the left side and make the right side 0.34. That way when the input is less than 0.34 it will activate the servo.
I mentioned this earlier.

Dear mci-ryan, I am struggling to understand what are you trying to achieve here.
Are you genuinely mistaken but trying to help or are you just having fun?

If it’s the latter then I will just carefully ignore any messages from you.

If it’s the former then hear me out:
You proposed “simplification” wouldn’t even compile. There is a loop which won’t work without a “defer” node. Seems like you haven’t tested your code before posting.
My “less” node behaves exactly as intended, outputting True for values >0.34. Perhaps it would be more appropriate to call it “more” but I just left the default name. So yes, when it’s 0.35 to max servo is being activated.
However, it doesn’t matter what is being compared there if you place the “if-else” downstream. It will be firing on both true and false, triggering the servo.
Please be more mindful when you post your advice. This could have damaged someone’s servo motor and would certainly upset anyone new to Arduino/XOD.

Your condescending attitude is pointless and your points are incorrect.
If-Else doesn’t “fire” anything on true or false. It’s simply a logic gate that allows the input to pass through.

You’re right about the defer… but that isn’t relevent… its only needed in the second screen clipping I showed you (which was YET ANOTHER thing that was posted to HELP you)

Your ridiculous comment at the end about damaging a servo motor is also ridiculous.

I gave you several options that would allow you to include a logic gate without having to adjust the C++ implementation to get the code work (via using the wrong node); pass-if, a standard gate, etc… You can do with that, what you wish.
Note: you also said that you ARE in fact, after ‘greater’ than 0.34 and that you should have have renamed it “more”. This is another indication of your ongoing inability to look in to using a node other than the one that you are currently using… why? because there is literally a node for “greater”.

In future, think about the fact that people are helping you and don’t be an arrogant clown.

1 Like

Your code does not work. not a single version you posted. I have tested it and reported the results to you every time.
I have never been rude to you but pointed out again and again the above.
Your anger and frustration, calling me names eventually, did not help at all
All I can do is report this thread to moderators.

The person who made the patch you referenced, liked my comment… anyone can see who has the condescending and arrogant tone here… do as you wish.