Yes, I saw that but not everyone is fortunate to have Protues and the there are basically no comments in the code as to what the intention of it is nor for which processor it's intended. But now we know :-)

Do you have the serial display in the actual prototype as well? In that case you can determine if the values are being read correctly and the logic is at fault OR if the problem is either with the code reading the ADC or possibly with the hardware itself.

Speaking of hardware, I don't see a single decoupling capacitor in the schematic. Things like that may fly in simulation, seldom in real life.

The code seems to decode the the expected ADC reading values correctly but what does it do when a value does NOT match one of the cases? For example if adc_res is 700? I think you should set b_level to 0 at the start of the routine. Not that THAT neccesarily is the problem but still....

Also, I think you should "release" the CS pin as soon as you've done shifiting in the data.

/Henrik.