Hello,
Programming mBot to react to sensors I need to see sensor value (like sound, light sensor values). As there is no possibility to “write” - I decided to write program to “show” number by lighting numbers of LEDs. I use “mod” to get last digit of number and show it - this way 258 will light 8 LEDs, then 5 LEDs, then 2 LEDs, so I will be able to understand it’s 258 (in reverse order). Each 3rd lighted LED is blue, to be easier to count them.
I created program:
Variable “Number” is any number I’d like to show. I tried with smaller and bigger ones, like 28, 2468 and so on.
The problem is, that it works incorrectly:
for 28 it lights 4,8,3 LEDs (it’s count, not LED id).
for 2468 it lights 3,8,7,5,3 LEDs (it’s count, not LED id).
So first number is “ghost” (sometimes there is no ghost number), then second is last number, displayed correctly, then all remaining numbers are +1 from value needed. I expected it might be “real number” approximation problem (as I see it “double” in Arduino C code), so I used “round” everywhere, but problem is still there.
Please advice.
Technical data:
mBot Ranger 3-in-1 (SKU 90092)
Windows 7, 64bit
mBlock v.3.3.0 (beta), 3.2.2 have no my mBot board support
Auriga board selected