This has come up in the past on this forum. In any case, the simplest way is to buy a system that incorporates the optics, sensor, and then outputs some digital stream to represent the data. There are some very inexpensive hand-held CCD scanners that output serial data you could then interface to your micro.
If you have to build one, the easiest way is the "wand" variety where you swipe a pen-like device across the barcode and let a phototransistor read the reflection on the paper of a bright LED. As long as you scan with a fairly constant speed, the length of time across each bar gives you an idea of how wide it is, you then have a lookup table to convert width to 1/0 or whatever. I used the input capture interrupts on my micro when I built such a device. Then I would just subtract the time from the last measurement.