Split number

Hi,

I want to create a speedo for my bike, with 3 7 segment screens to display the km/h

For the 7segment screens I’m using the MAX7219. However, you need to say which digit must be displayed on which screen.

The value (in km/h) is mostly more than one digit. For example, if it’s 12.4 I need to say that the MAX7219 needs to display a 1 on screen1, a 2 on screen2 and a 4 on screen3.

How can I take a number apart and split it up in to three characters?

For the following code:
mydisplay.setChar(0,0,val1, false);
mydisplay.setChar(0,1,val2, false);
mydisplay.setChar(0,2,val3, false):

Where val 1 = the first digit, val 2 = second digit and val 3 is the third digit, after the comma.

How can it be done?

Thanks!

Jens

How can I take a number apart and split it up in to three characters

Base 10 arithmetic.

Hello

See http://stackoverflow.com/questions/9302681/c-how-to-break-apart-a-multi-digit-number-into-separate-variables

The way you put three characters together to make a number, but in reverse! :slight_smile: