With my son I tried to extend the Balance Game to use two Circuit Touch inputs instead of only one. The idea was to keep the zeesaw level when no inputs were touched, make it tilt left when one input is touched and tilt right if the other input is touched.
Trying with List
Inspired by this question about the Gate component I used a List, list1, with the input connected to a Circuit Touch component to output either of these values:
- item 0 (untouched): the output of another List (list2)
- item 1 (touch detected): a fixed value of 0.35
The List, list2, is connected to another Circuit Touch component to output:
- item 0 (untouched): fixed value 0.42
- item 1 (touch detected): fixed value: 0.5
With no circuits touched I would expect 0.42 to be output. However, when the QuirkBot is powered on, it moves the servo all the way to the left (I guess this means that the output is zero). After touching the inputs and letting go again, the value 0.42 is output and the zeesaw is level.
I guess this is similar to the hold logic of the Gate component such that the List components output 0 and hold it until the first change is detected on the input. Is that right?
Using Converters instead
Doing exactly the same but using two Converters (instead of Lists) wired in cascade as above makes it work as intended: when the QuirkBot is powered on the zeesaw is level.
It seems the output of the Converter component is defined initially while the List is in “hold” mode until its input changes.
Any ideas how this could be pulled of in the block programming environment in a more elegant way?
Missing a Math alternative…
I guess the easiest way would be to be able to combine two inputs in a function – e.g., Add. Then I would first invert one of the inputs using a Converter and then combine them with a Add combinator. However that does not exist, yet…
A general Function component would be nice where you could wire multiple inputs and write an expression to define the output – e.g., input1 + input2.