A 106 mg robot the size of a fly uses a light sensor to stabilize flight, the first demonstration of onboard sensing in a flying robot at this scale. (inset) The visual sensor, a pyramidal structure mounted at the top of the vehicle, measures light using four phototransistors and is inspired by the ocelli of insects (scale bar, 5 mm). (main) Frames taken at 60 ms intervals from a video of a stabilized flight in which the only feedback came from the onboard vision sensor. The sensor estimates pitch and roll rates by measuring changes in light intensity arriving from a light source mounted 1 m above (not shown). This is used in a feedback loop actuating the pair of flapping wings to perform continuous corrective manoeuvres to stabilize the upright orientation of the vehicle, which would otherwise quickly tumble (see §5). A wire tether transmits control commands and receives sensor feedback, acting as a small disturbance that does not augment stability. (Online version in colour.)