Go Down

### Topic: 7-Segment Display Wiring and Programming (Read 92730 times)previous topic - next topic

#### guitarboy667

#45
##### Jan 20, 2011, 06:43 pm
I get how to control the decimal points, but I just wanted to make sure that when the integer was converted into bytes the decimal was kept.

#### guitarboy667

#46
##### Jan 20, 2011, 06:53 pmLast Edit: Jan 20, 2011, 06:54 pm by guitarboy667 Reason: 1
I put the delay at the end.  The code I was running didn't have anything else in it, so as soon as it finished sending say 68 it was sending another 8 through that got rid of the 6.

#47
##### Jan 20, 2011, 09:12 pm
Okay, so split it  up & send it out.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#48
##### Jan 20, 2011, 11:27 pm
How do I split it and how do I keep the decimal?

#49
##### Jan 21, 2011, 05:45 am
I presented a way to do that earlier:

"Your other question: I need to know more what a number like 2,593 is.
Are those 4 hex digits?
There are ways to separate it into digits.
For example,  hex data  digit = 2593:
digit0 = digit AND 0x000F  now digit0 = 0003
digit1 = digit >>4 now digit 1 = 0259 (shifted 4  bits away)
digit1 = digit1 AND 0x000F now digit1 = 0009
digit2 = digit1 >>4 now digit2 = 0025
digit2 = digits AND 0x000F now digit2 = 0005
digit3 = digit2 >>4 now digit3 = 0002"

Try this:
digit = 0x2593;

digit0 = digit && 0x000F;  // mask off the upper 12 bits
Serial.print (digito, HEX);
digit1 = digit >>4; // shift off the lower 4 bits
digit1 = digit1 && 0x000F; // mask off the upper 12 bits
Serial.print (digit1, HEX);
digit2 = digit >> 8; // shift off the lower 8 bits
digit2 = digit2 && 0x000F; // mask off the upper 12 bits
Serial.print (digit2, HEX);
digit3 = digit >> 12; // shift off the lower 12 bits
digit3 = digit3 && 0x000F; // mask off the upper 12 bits
Serial.print (digit3, HEX);

I don't know where the decimal point goes, not enough info provided.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### guitarboy667

#50
##### Jan 22, 2011, 08:02 am
Those would be int numbers not hex, but did you provide a conversion from into to hex in the beginning of the code? If so, then that should work.

The thing is I want to display a calculated number stored in a variable.

So say
x= 36.3
or
x=2.58

Ideally I'd like to be able to convert x into something to send to the 7-segment displays.

#### guitarboy667

#51
##### Jan 22, 2011, 08:51 pm
Non-ideally I'd like to get the decimal between the last 2 digits. (234.5 for example)

Thanks for your help man.