Recalling what we said about the trigger, we can implement these two solutions for the threshold:
using a trimmer we can manually set a voltage level;
using the PWM of the Arduino we can set the level by software.
On the image we can see the hardware implementation of the threshold in both paths.
For the manual selection, a multi-turn potentiometer put between +5 V and GND is sufficient.
While for software selection we need a low-pass filter that filters a PWM signal coming from the Arduino. PWM signals (more on this to follow) are square signals with a constant frequency but a variable pulse-width. This variability brings a variable mean value of the signal that can be extracted with a low-pass filter. A good cutoff frequency for the filter is about one hundredth of the PWM frequency and I chose about 560 Hz.
After the two threshold sources I inserted a couple of pins that allows to select, with a jumper, which source I wanted. After the selection I also added an emitter follower to decouple the sources from the Arduino pin.