Project with servo

The thing is... I deleted everythink because nothing worked. I spent 3h on the code and 1 searching for answers. It´s frustrating and because of that i deleted everythink.
Right now the only code i have is the first part of my project but that is funcional and has nothing to do with this part.
I dont have any degree or something in anything this type, i just like this things and i tried to do somethink at home alone.