I need to get the individual number from a time so i can output a nibble to a BCD to 10 decoder. So, if the time was 12:30 i need to find the 10s of hrs, hrs, 10s of minutes and minutes, so 1, then 2, then 3, then 0.
Im getting the time from a ds1307, so i can get just the hrs and just the minutes, but cant split them up! any help gratefully recieved.
What's your own mental process when you think about a number, if you want the "tens" and "units"?
The number 43 is ten times four, plus three. The number 43 divided by ten is four with a remainder of three. One way to get the remainder of a division is with the modulo operator. http://arduino.cc/en/Reference/Modulo
Trying to nudge you to a solution, rather than just handing you the two lines of code it takes.
yeah i appreciate it! i can see how to get the tens, all im doing is dividing it by ten so with 12 i'd get 1.2 and becasue its not a float it ignores the .2 giving me just the 1. However it was the units that had me stumped! i shall research the modulo operator now! Thankyou!
Nope, the / does the division and keeps the whole number (unless the variables are float type). The % (modulo) does the division and keeps the remainder.