Added  the final tuches to the code (note that some of the digital io
sensors might be inverted)