Thanks for the help

.i think i figured it out

It would help if you posted a schematic showing the way you wired it, including power supplies and all interconnections. Links to each hardware item would help. I looked at your link, I do not have the time to study it then interplate what you did.

Nice Schematic but not complete. The CKIN pin needs an 33pF, the schematic I have is a but fuzzy and shows .33pF. From what I see you have done it correctly. The only thing I see in the code is your case statement has no exit if there is no valid case. You may try printing each case out as you sequence and see where the error is. The schematic is not complete, the source for the 5V is not shown Vin will not work properly with 5V it needs at least 7v or more.