clearwater / SwitecX25

Arduino library for Switec X25.168 and friends
http://clearwater.github.com/gaugette/
Other
128 stars 44 forks source link

Not a bug! But i need some explanation! #18

Closed ramimehyar closed 2 years ago

ramimehyar commented 2 years ago

Hello Guy,

Can you please please explain to me the variables you are assigning to the character c...

I understand your driver pretty well, but i do not understand the example part:

if (Serial.available()) { char c = Serial.read(); if (c==10 || c==13) { motor1.setPosition(nextPos); nextPos = 0; } else if (c>='0' && c<='9') { nextPos = 10*nextPos + (c-'0');

Regards,

Rami

guyc commented 2 years ago

Hi Rami,

That's a basic ASCII decimal decoder for testing over the console. It would for example decode the input sequence of '1' '2 '3' [enter] into the integer value of 123 and call setNextPosition(123).

ramimehyar commented 2 years ago

Oh! I should have known this!

So it is similar to the function Serial.parseInt()

Thanks!