OK. I’m trying to take this a step at a time and I am having trouble. I think there are subtleties of XOD that I do not understand.
The goal: make my Elegoo robot car move forward when there is no obstacle in front; move backward when there is an obstacle in front. (I have not tried to implement a loop yet. I’m just trying to get it to work if it starts with the “road clear” or with an obstacle in front.)
I want to take ultrasonic sensor readings and, depending upon the reading, make the car go forward or backward. I first approached this by determining if I could “interrupt” the forward motion of the car. I was able to do this with a delay node, like this:
The timer is set to 10 seconds. It’s “Set” pin is set to trigger “on boot.” The motor’s “On” pin is set to trigger “on boot.” On boot, the delay and motor are both “booted”. When the delay finishes, it pulses the “Stop” pin of the motor and the motor stops. This works. So far so good.
So, all I have to do is trigger the “Stop” pin of the motor with the ultrasonic sensor to stop the motor, correct? Not so fast.
Here is my node to stop the motor by triggering the “Stop” pin with the ultrasonic sensor. If the distance in inches read by the sensor is greater than 0 and less than 20, then the “Stop” pin is triggered via a “pulse on true” node. Otherwise, the motor “On” pin is triggered via a “pulse on false” node. But, instead of this expected behavior, it just runs continuously regardless of whether there is an object in front or not. I don’t know why.
For anyone interested, my motor patch is just a custom gweimer/h-bridge with default pinouts for my Elegoo car (and some pin label changes and remapping of “speed” inputs). Here is the patch for my motor:
And here is the patch for my ultrasonic sensor:
I am finding that often I will construct a patch that works in isolation, but when I combine it with another, or others, it stops working. I think there is some subtlety in the signaling that I do not yet understand. (By the way, I have read the documentation on “Concepts” [including the execution model and linking rules, among other things].)