A latching trigger

Why use an encoder rather than a standard potentiometer? Seems like as a beginner to coding this sort of stuff processing the analog in from a pot will be much easier than following the flow of an encoder.

How are your light sensor set up? Voltage divider?

To save you some time in your coding i will tell you that

if((up == HIGH) && (old_up == LOW))

is the same as

if(up && !old_up)