diy camera slider

i am working on a DIY camera slider via youtube, i don't know any programming. i have attached the sketch i am using. most part is working fine with few glitches. since programming is not my piece of cake, i am not expecting a perfect piece.
problem i am facing is the motor keeps running even if i hit the limit switch which will damage the hardware.
i want to reverse direction as soon as it hits the limit switch whatever be the time duration is set, i just want it to reverse direction,
please help me with the sketch, which command to add so as it reverses direction.
also my menu fonts are too small, how to increase its size so as i can read. i tried increasing font size to 2 at many places, but texts just gets cropped on screen and is useless. please help soon. i have invested lot in parts.

functions.cpp (1.77 KB)

functions.h (441 Bytes)

menuStuff.cpp (7.08 KB)

menuStuff.h (723 Bytes)

MotorizedSliderV2.0.ino (4.11 KB)

README.txt (66 Bytes)

  pinMode(8,INPUT);

What is connected to pin 8? How?