I am making a program to monitore datas like voltage, current, temperature etc. The project will use 4 displays, in the moment I am just using two displays with i2c. I am using the arduino MEGA 2560. When I compile the program I can see just "27:85:85" in both displays.... What is the problem with my code?
You are using a function (called ConverteParaBCD), to do some conversion.
It takes a value, divides it by 160, and then takes part of that same value and adds it to the first result, correct ?
Is that really what you mean to do ?
You are using a function (called ConverteParaBCD), to do some conversion.
It takes a value, divides it by 160, and then takes part of that same value and adds it to the first result, correct ?
Is that really what you mean to do ?
I don't see that.
I see:
byte ConverteparaDecimal(byte val)
{
//Converte de BCD para decimal
return ( (val/16*10) + (val%16) );
}
That function looks ok to me to convert BCD to decimal.
val/16*10 is not the same as val/160
It is the same as (val/16) * 10 which is the same as (val >> 4) * 10