Go Down

### Topic: split a number up for the 3 digits (Read 8656 times)previous topic - next topic

#### db2db

##### Sep 18, 2011, 04:57 am
I have a number up to 999, and now I want to send that data to three 7 segment LEDS.

Is there some standard way that is used to do the math of ones tens etc, to break that number down into the single digit components to send to each display?

Thanks!

#### RuggedCircuits

#1
##### Sep 18, 2011, 05:15 am
Code: [Select]
`uint8_t ones,tens,hundreds;hundreds = number/100;number = number-hundreds*100;tens = number/10;ones = number-tens*10;`

--
The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O's fused and protected

#### liuzengqiang

#2
##### Sep 18, 2011, 05:17 am

I have a number up to 999, and now I want to send that data to three 7 segment LEDS.

Is there some standard way that is used to do the math of ones tens etc, to break that number down into the single digit components to send to each display?

Thanks!

first=number/100;
second=number%100/10;
third=number%10;

#### db2db

#3
##### Sep 18, 2011, 05:42 am

This looks nice and easy.

Much appreciated.

#### liuzengqiang

#4
##### Sep 18, 2011, 06:20 am
No problem. This question is quite typical and gets asked like once a week.

#### db2db

#5
##### Sep 18, 2011, 06:26 am
I assumed so, but could not find it on here.

Thanks.

#### liuzengqiang

#6
##### Sep 18, 2011, 08:05 pm

I assumed so, but could not find it on here.

Thanks.

They don't always manifest the same way but this one I answered was pretty similar. Don't worry. It's a typical thing that we help newbies with the same questions over and over, as long as they're respecting the forum and provide enough information to get answers.

http://arduino.cc/forum/index.php/topic,72575.msg544298.html#msg544298