Print UInt number on two ports (solved)

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Print UInt number on two ports (solved)

Post by bercioiu »

Hi all!

I have a counter from 0 to 65535 that i want to "print" it to port A and port B, and I1m stuck up... I dont know how to do it...
I use Port A for 0 to 255 and port B for 256 to 65535.
Please show me the way to see the light :-)

Thanks!
Last edited by bercioiu on Sun Jul 29, 2018 12:55 pm, edited 1 time in total.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Print UInt number on two ports

Post by kersing »

Use a calculation icon to split it into two byte sized variables like this:

(Create two variables counter_low and counter_high of type byte)

Code: Select all

counter_low = counter & 255
counter_high = (counter >> 8)
Now you can use these to set port A & B.

(If you want to you can skip the variables and just use counter & 255 as the argument for one output icon and counter >> 8 for another output icon)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

bercioiu
Posts: 161
Joined: Sun Feb 25, 2007 10:56 am
Location: bucharest, romania
Has thanked: 90 times
Been thanked: 34 times
Contact:

Re: Print UInt number on two ports

Post by bercioiu »

Thank you very much, sir! You told me exactly what I did not know!

Post Reply