revised indicator levels; better error checking; gpio mode setting