balanced gray code on arduino with transition sequence