Go Down

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

db2db

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

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

liudr


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


This looks nice and easy.

Much appreciated.

liudr

No problem. This question is quite typical and gets asked like once a week. :D

db2db

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

Thanks.

liudr


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

Go Up