Pages: 1 2 3 [4]   Go Down
Author Topic: 7-Segment Display Wiring and Programming  (Read 62774 times)
0 Members and 3 Guests are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 20, 2011, 12:54:03 pm by guitarboy667 » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27089
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, so split it  up & send it out.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I split it and how do I keep the decimal?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27089
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Non-ideally I'd like to get the decimal between the last 2 digits. (234.5 for example)

Thanks for your help man.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27089
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So what do the "two 7-segment displays of 4 digits each" represent?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: 1 2 3 [4]   Go Up
Jump to: