modified read func to take pin as argument

This will make it easier to use several sensors at the same time