This PLC ladder logic code may work for an automatic stair lights system. The program is supposed to drive a strip of ten lights placed along a stair. Controlled by top and bottom photocells, the lights will turn on and off one at a time; the sequence depends on your walking direction.

Due to count instructions, the lights will back dark when there is no one on the stair. For that reason there must be a pair of photocells (distant few centimeters each other) at each end of the stair: depending on the sequence of activation they will generate a positive or negative count signal.

Timers from T1 to T10 turn on and off the lights from L1 to L10, through the instructions K1 and K4.  Lights from L10 to L1 are controlled by the timers from T1A to T10A, through the instructions K2 and K3.

The code has been tested with a  simulation software.  You may use a PLC for an home system which manages several automatic controls and requires an high reliability level. 

If you need just an automatic stair lights controller, you may use cheaper devices, such as Arduino and Raspberry, or try this.