Instructions
Clamp around bar and do up 2 off M4x40 with washers and trapped nuts spaced diagonally. Glue optical or mechanical sensor to platform with hotmelt glue or epoxy. Ensure it lines up with the sensor's activator!
I tend to use small, lever-action microswitches and solder them to a bit of board. The board carries a connector and a 100K resistor (brown-black-yellow) to limit current through the switch when it connects to either 5V or the ground rail.




