Your circuit change is wrong.
The 4K7 resistor goes from pin7 in your earlier circuit to the 5v+ track.
Hence the ....pullup expression, it pulls the output to 5v+ when the tranistor in the LM311 ts switched off.
The picaxe needs to see a change in voltage on the input pin between 0 volts and 5 volts, when the LM311 is switched on pin 7 it will be 0 volts, but when it is switched off there is nothing to pull the line high so the picaxe will still only see 0 volts on the input pin, hence the pullup resistor, when the LM311 is switched off the pullup takes the input pin of the picaxe high, giving a 0 to 5v change on the input pin of the picaxe.
If you dont understand then email me the express art work and i will change it to be correct for you.
Pete.