This small project is just a remix of two earlier examples to make something potentially useful. We will combine the Distance Sensor Switch and a servo. Start with the custom Arduino node to control a servo that was set up in the Servo example. I also have the distance sensor plugged into my bread board.
In my Embrio project I set up the sensor to act as a switch as I did in the previous example. I make an input that reads pin A2, pass its activation through a value lag node, and pass the lagged value into an Above Or Below node. I add a switch node and attach the Go Above trigger to its Toggle input. Now the switch is turned on and off by holding my hand in front of the sensor for a moment. Finally I attach the switch’s activation into the custom Arduino node to control the servo. Now I can switch the servo between two positions using the sensor as a switch. I can also adjust the servo positions by changing ton On and Off value inputs on the switch node.