Later systems use a "hot wire" to figure it out. When you turn your engine on, the wire becomes red hot. As air is sucked past this wire, it gets a little cooler. The car's brain measures exactly how much cooler it's getting and uses this number to figure out how much air it's sucking. Then it squirts the correct amount of fuel into the engine.
There are lots and lots of variations to fuel injection systems. We've got electrnic fuel injection, mechanical fuel injection, systems with one oxygen sensor, systems with four oxygen sensors ... but the basics remain the same.


