Added some check and costantes

I added pin_exist function to check if the port is supported
I added some costants
I resized some variables
I added return value to check error
I clean the code.