Photosensor - how to program adjustment to room's lighting

I took it from a tutorial that also suggests an automatic way to do it- but it's just reading on and off:

That snippet you posted doesn't read anything.

We can't see how, or if, you call that function.