Pages: [1]   Go Down
Author Topic: [SOLVED]splitting int to print each value to 7seg  (Read 301 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi folks, checked everywhere for this, for a long time now. checked here and the reference, experimented with highbyte, lowbyte etc. example, using max7219, wanting to take a value say "24" split it to write "2" to one segment, and "4" to the other. thanks.

Code:
int =24
Serial.print((a/10)%10);
Serial.print(a%10);

results = a "2" and a "4".
« Last Edit: January 20, 2013, 10:19:21 pm by grendle » Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 514
Posts: 26252
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

You've got a couple things there.

24 in decimal is 0x0018, so highbyte & lowbyte will give 0x00 and 0x18, not really what you want.

If you use the modulo command I think you can split 24 decimal into 2 and 4.

Then its just a matter sending the data to the appropriate registers in the MAX7219.
I believe register 1 would be digit 0 for the 4, and register 2 would be digit 1 for the 2 in your example.
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.

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok great thanks! back to work now lol. ya the 7219 is working fine no issues where to send the values, just need to split it. let me start thx again.


hmm looks like modulo just does division? still messin with it. NOPE  that did it. thank you. works fine, ez too. solution in op.
« Last Edit: January 20, 2013, 10:24:43 pm by grendle » Logged

Pages: [1]   Go Up
Jump to: