Detecting each of up to 16 different things

Henry_Best:
I have toyed with the idea of a self made barcode stuck to the underside of each wagon to identify it and reading this with an IR LED and detector, but don't know how to detect the start of the read cycle and how to control the timing of reading each bar. Although the speed will be quite slow, it may not be constant.

Assuming you've rigged up your IR reflectance sensor right (and that's a big assumption), it should trigger low when the white label of the barcode starts as hopefully the barcodes are the only reflective thing passing over the sensor.

Design your barcode with a black line three units wide in the front. Using pulseIn() you can measure the time it takes for the bar to pass over the sensor and now you've got your reference time. The remaining bars in your barcode are then either two or one unit wide and comparing those times to your reference you know if you've got a binary one or zero.