Convert a decimal number into a String?


hey there, i'm trying build basic counter test figuring out how interface multiple 7-segment leds.

i've got basic setup running per tutorial on arduino site, , can send arbitrary character bytes both leds, , have created basic lookup table characters 0 9, , blank (all segments off).

what i'm trying increment variable (the counter), , extrapolate appropriate bytes shift out based on individual numerals make counter decimal number.

for example, if i'm trying write number "72" leds, i'd  be able convert number 72 string, grab digits one-by-one using kind of string operation, convert each single digit individually integer,  use integers assign appropriate byte lookup table, , repeat until of digits have been shifted shift registers.

problem (and find super surprising), i'm discovering arduino has no convenient way either:  a) convert integer string, or b) grab substring of given string.  

most of programming i've done has been using flash/actionscript , guess sort-of took granted arduino/c++ have similar string operation functions and/or integer string conversion (arduino seems map converted integers ascii character value or instead of converting digits literally)

which leads me 3 possible conclusions:

1. i'm missing regards working ints/strings in reference material

2. i'm thinking problem wrong, , there's another, logical , straightforward way take decimal number , extrapolate appropriate bytes send shift registers

3.  both of above..!

off top of head occurs me might able solve problem running series of cascading incrementing variables count 0-9 (one variable each shift numeral i'm trying display), seems bit... hacky , indirect.  being able display arbitrary multi-digit integer directly seems lot more elegant , useful.

any advice appreciated!

-t   :-?

quote
problem (and find super surprising), i'm discovering arduino has no convenient way either:  a) convert integer string, or b) grab substring of given string.


problem is, arduino has little memory, , full implementation of sprintf, left/right justification formats, hex/decimal/string formats memory-hungry, general string handling. but, have these functions.

however, yes, there other ways around these, not @ hacky.
constant tables spring mind.


Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > Convert a decimal number into a String?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums