added the working sample code
added timeout ability for pulsein
happy with this method of coding