Tengo un código en el que la variable "year" tiene como valor 12, lo se seguro porque hago print year y sale 12
Pues cojo y dentro de la siguiente función incluyo esto:
year = year + 2000;
Y cuando hago print year me sale 220 en vez de 2012 ![]()
como lo puedo hacer?
void getDateDs1307()
{
// Coloca el cursor en el registro 0
Wire.beginTransmission(DS1307_I2C_ADDRESS);
I2C_WRITE(zero);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
second = bcdToDec(I2C_READ() & 0x7f);
minute = bcdToDec(I2C_READ());
hour = bcdToDec(I2C_READ() & 0x3f); // Need to change this if 12 hour am/pm
dayOfWeek = bcdToDec(I2C_READ());
dayOfMonth = bcdToDec(I2C_READ());
month = bcdToDec(I2C_READ());
year = bcdToDec(I2C_READ());
================> year = year + 2000;
}