 # decimal number

I am using 2, 7 seg displays. I want to put a number from 00 to 99 on the displays. Iam having a difficult time doing this any suggestions?

My suggestion is to read the "How to use this forum" post and follow the directions.

Use a seven segment display library appropriate for your display.

Get one display to work, before you add the other.

I can get one digit to work . So it can go from 0 to 9. Is there a way of separating the two digits so I could have for example instead of 53 I can now have a 5 and a 3 ?

Yep

(same amount of info in the answer as there is in the question)

In the Arduino Language Reference, you should look at the division and remainder operators.

Ok, I am sorry this is my first post. I am working on taking an analog signal through a map function to get it to a 0 to 99 number. I am using the 7 seg display as an interesting way to do it. My problem is trying to get the number to a form that can be sent to the displays. I have the displays working with a different program that counts from 0 to 99 then repeats. So I know the circuitry is working correctly.

Is there a way of separating the two digits

Did you happen study the decimal number system in grade school? For example, were you taught how to think about the differences between the "5" and the "3" in the number 53? If so, consider reviewing that information.

newbie1231:
I have the displays working with a different program that counts from 0 to 99 then repeats.

Did you write that other program?
If not, when you read through the code of this other program, can you follow what it is doing and how?

I did not write the other program. I can use parts of it. Yes, I understand what the program is doing.

This is the program

//Displays digit 0 - 9 and decimal point

int segPins = {9,8,7,6,5,4,3,2}; // (a b c d e f g .)
int displayPins = {10, 11}; //pin 10 controls D0, pin 11 controls D1
int displayBuf; // The display buffer contains the digits to be displayed
// displayBuf contains the LSD, displayBuf th MSD
byte segCode={
//a b c d e f g .
{ 1, 1, 1, 1, 1, 1, 0, 0}, // 0
{ 0, 1, 1, 0, 0, 0, 0, 0}, // 1
{ 1, 1, 0, 1, 1, 0, 1, 0}, // 2
{ 1, 1, 1, 1, 0, 0, 1, 0}, // 3
{ 0, 1, 1, 0, 0, 1, 1, 0}, // 4
{ 1, 0, 1, 1, 0, 1, 1, 0}, // 5
{ 1, 0, 1, 1, 1, 1, 1, 0}, // 6
{ 1, 1, 1, 0, 0, 0, 0, 0}, // 7
{ 1, 1, 1, 1, 1, 1, 1, 0}, // 8
{ 1, 1, 1, 1, 0, 1, 1, 0}, // 9

};

void refreshDisplay (int digit1 , int digit0)
{
digitalWrite(displayPins, HIGH); //displays digit 0 (least signifigant)
digitalWrite (displayPins , LOW);
setSegments(digit0);
delay(5);
digitalWrite (displayPins, LOW); //then displays digit 1
digitalWrite (displayPins, HIGH);
setSegments (digit1);
delay(5);
}

void setSegments(int n)
{
for (int i=0; i < 8; i++)
{
digitalWrite(segPins_, segCode[n]);_
* }*
}
// ******************************************
// ******************************************
void setup() {
* for (int i=0; i<8; i++)*
* {*
_ pinMode(segPins*, OUTPUT);*_

* }*
* pinMode(displayPins, OUTPUT);*
* pinMode(displayPins, OUTPUT);*
* displayBuf = 0; // initializes the display*
* displayBuf = 0 ;*
}
int i =0, j = 0;
int startTime = 0;
int endTime ;
// *****************************************
// *****************************************
void loop() {
refreshDisplay(displayBuf, displayBuf); //Refreshes the disply with the contents of display b
* // after each iteration*
* endTime = millis();*
* if ((endTime - startTime) >= 1000){*
* if(++i > 9)*
* {*
* i = 0;*
* if (++j > 9) j = 0;*

* }*
* displayBuf = i;*
* displayBuf = j;*
* startTime = endTime;*

* }*
* }*

Did you made it italic? Aka read How to use the forum.

Although people just hint it, they are right. Just go back to grade school and transform 54 into 5 an 4 Something to do with decimal Thanks very much for the help

As septillion pointed out, where your code changes to italic font, that is where an [ i ] was originally, that we can now not see. Using code tags prevents that.

If you want to separate the 10’s from the 1’s, you can use the division and remainder operators as I mentioned in reply #6. You can then assign those to displayBuf and displayBuf respectively.

Thanks for the suggestion I started to do this and it will ok . I take the original number divide by ten then store the number as an int. This gets rid of the 3 and I have 5. Then to get the 3 I multiply the 5 by ten then subtract this from the original number.
Thanks

No need to store it Just doing 53/10 will result in 5 And as for the 3, that is an option. You could also use modulo Here is another way, without division:

``````int num = 53;

int tens = 0;
int ones = num;

while (ones > 9) {  // As long as there are more than 9 ones:
ones -= 10;       // Decrease the number of ones by 10
tens++;           // Increase the number of tens by 1
}                   // Lather, rinse, repeat
``````