added encoder code for arduino