I would to read last 4 bit of data.
Ex:
Data = FA ' hex
4bit.low = 10 'Dec
4bit.high = 15 'Dec
Printable View
I would to read last 4 bit of data.
Ex:
Data = FA ' hex
4bit.low = 10 'Dec
4bit.high = 15 'Dec
4BitLo = Data & $0F ' = 10
4BitHi = Data >> 4 ' = 15
(See manual or online for & and >> details)
Thank you paul borgmeier
I have 1 question...
How to convert Hex to Dec?
we try to do 7seg display time.
If we need to show minute 10 , sec 20
n = Value Dig i ' Get digit to display
So, how to store data minute and sec in to Value = 2010 (dec)
where the data comes from?
anyways, the following should work
Code:'
' HEX to DEC
' ----------
Decimal=((Hexadecimal>>4)*10)+(Hexadecimal & $0F)
'
' DEC to HEX
' ----------
Hexadecimal=((Decimal/10)<<4)+(Decimal // 10)
Chai98a,
If you have enough RAM, it is easier to keep the seconds, minutes, hours, etc., all in their own variable. This saves building and unbuilding combined variables each time a second passes. I have posted two examples of clocks here
http://www.picbasic.co.uk/forum/showthread.php?t=2129
that uses separate variables for each “item”. The code sections of interest for you are at the very end of the programs. The first only has minutes and hours but seconds could easily be added. The second has all three. Check them out and see if they might help.