It's not too hard to concieve of a metabolic pathway in a bacterium that would supply more or less energy to the flagellum based on the intensity of light at another part of the bacterium
Apologies if I get this a bit wrong, as it's a while since I covered this, and I'm doing this from memory and a quick look at Alberts et al. The way it works is something like this:
The flagellum have a very dinstict 'handedness', and as may have been pointed out already can spin in both directions. This is what causes the run and tumble effect that Sylas has mentioned. When the flagellum turn in one direction then they all effectively work together and the E Coli (or whatever) 'runs' in one direction. Every few seconds the flagellum turn the other way and the cell 'tumbles' on the spot.
Without the presence of stimulus then this is effectively random, but there are mechanisms that will 'sense' certain chemicals (and possibly sunlight, although I'll have to check that), and these will effect the direction of turn of flagellum and hence make the bacteria travel towards or away from stimulus.
Hope this helps
Edit: overexcitable typing
This message has been edited by Ooook!, 05-21-2004 08:43 AM