Add a "state" variable. That variable keeps track of what was the previous change.
For example, the robot starts on black. Set the state to 1 as black. In the loop, check what the reading is. If it is still black, don't do anything. Basically, while it is on the black, it checks to see if the state is at black, and if it is, that means the robot didn't move.
If the reading is white, and the state is black, that means it has changed state. Set the state to 0 for white, and then repeat the above, except ignore the values that are white, since the state is already white.