Another set of eyes
This code right here· I want to take in values from 100 to 220 and send over xbee wirelessly. I get it to send the numbers just fine but included is the start symbol too. My first question is how would I get rid of the "$" after the number is read in to just display the number. My next question is when I add the case statement in it acts all funny. I just want it to compare the whole value. This is to control and ESC for a foam jet using a keyboard (testing phase now until I can implement the joystick with throttle
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
{{XBeeSpeedControlDemo.spin}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
pin = 4
CR = 13
VAR
long idx, cptr
byte throttle[noparse][[/noparse]256], prevThrottle[noparse][[/noparse]256], bFound, XBbuff[noparse][[/noparse]40], dataIn
OBJ
ESC : "ElectriflyESC"
XBee : "XBee_Object"
Term : "FullDuplexSerial"
PUB main
'Setting up XBee to start recieving on this end
XBee.start(10, 9, 0, 9600)
XBee.AT_Init
XBee.AT_Config(string("ATAP 0")) ' Set for non-API mode (AT mode)
XBee.AT_Config(string("ATDL 1")) ' Set Destination Location to 1
'Setting up serial port params for debug term
Term.start(31, 30, 0, 19200)
waitcnt (1_000_000 * 25 + cnt )
'Initializing the ESC
'ESC.initialize
'ESC.delay(500)
readData
PUB readData
repeat
dataIn := XBee.Rx
if dataIn == "$" ' ASCII $ characte
bFound := 1
if bFound == 1
if dataIn == CR
throttle[noparse][[/noparse]idx] := 0
idx := 0
bFound := 0
Term.str(@throttle[noparse][[/noparse]0])
Term.tx(10)
Term.tx(13)
else
throttle[noparse][[/noparse]idx] := dataIn
prevThrottle[noparse][[/noparse]idx] := throttle[noparse][[/noparse]idx]
idx++
case @throttle & @prevThrottle
@throttle > @prevThrottle:
Term.Str(String(10, 13, "Throttle increase: "))
'ESC.throttle(pin, throttle)
@throttle < @prevThrottle :
Term.Str(String(10, 13, "Throttle decrease: "))
'ESC.throttle(pin, throttle)
OTHER:
Term.Str(String(10, 13, "Throttle did not change: "))
'ESC.throttle(pin, throttle)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!

Comments
- CASE is not what you want; read Chapters 3 and 4 of the Manual to learn more about SPIN
- To compare numerical values you have to convert them into binary format... lots of examples everywhere, as this is a typical beginners problem every week
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!
Nevertheles, just use numbers#DEC as format and it might work...