What is this object in the cockpit of an ultralight?
It's an airspeed indicator for ultralights.  The pitot inlet is at the bottom and the pitot air pushes a little red plastic disc up and down on a central rod, with a calibrated clearance between the edge of the disc and the walls of the tube.  They are very sensitive and are good down to 10 MPH or less.  You'll also see them on hang gliders. 

See here:
https://www.aircraftspruce.com/catalog/inpages/hallwindmeter.php?clickkey=5468