74hc164 + 2x 4511 bcd decoder
hi everyone.
i'm trying use 2 bcd decoder 1 74hc164.
if use
i'll number 9 in both displays.
i need make function convert dec number i.e 34 into b00110100 so can send 74hc164.
thanks everyone!
cheers
i'm trying use 2 bcd decoder 1 74hc164.
if use
code: [select]
shiftout(data, clock, lsbfirst,b10011001);i'll number 9 in both displays.
i need make function convert dec number i.e 34 into b00110100 so can send 74hc164.
thanks everyone!
cheers
the value 34 consists of 2 digits. can separate 2 digits separate variables:
now, need convert each digit binary representation.
there shorter ways of doing this, works, , easy understand.
code: [select]
byte num = 34;
byte digit1 = num / 10; // digit1 3
byte digit2 = num % 10; // digit2 4now, need convert each digit binary representation.
code: [select]
byte b[4];
if(digit >= 8)
{
b[0] = 1; // if digit 8 or 9, first position 1
digit -= 8;
}
else
b[0] = 0; // otherwise, it's 0
// digit 7 or less
if(digit >= 4)
{
b[1] = 1; // if digit 4, 5, 6, or 7, 2nd position 1
digit -= 4;
}
else
b[1] = 0; // otherwise, it's 0
// digit 3 or less
if(digit >= 2)
{
b[2] = 1; // if digit 2 or 3, 3rd position 1
digit -= 2;
}
else
b[2] = 0; // otherwise, it's 0
// digit 0 or 1
b[3] = digit;
there shorter ways of doing this, works, , easy understand.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > 74hc164 + 2x 4511 bcd decoder
arduino
Comments
Post a Comment