balanced gray code on arduino by using transition sequence