When the Magsafe connector is plugged into a Mac, a lot more happens than you might expect. I believe the following steps take place:
The charger provides a very low current (about 100 µA) 6 volt signal on the power pins (3 volts for Magsafe 2).
When the Magsafe connector is plugged into the Mac, the Mac applies a resistive load (e.g. 39.41KΩ), pulling the power input low to about 1.7 volts.
The charger detects the power input has been pulled low, but not too low. (A short or a significant load will not enable the charger.) After exactly one second, the charger switches to full voltage (14.85 to 20 volts depending on model and wattage). There’s a 16-bit microprocessor inside the charger to control this and other charger functions.
The Mac detects the full voltage on the power input and reads the charger ID using the 1-Wire protocol.
If the Mac is happy with the charger ID, it switches the power input to the internal power conversion circuit and starts using the input power. The Mac switches on the appropriate LED on the connector using the 1-Wire protocol.