Hola a todos buenas tardes, como estan? antes que nada agradecer a todos ya que gracias a este foro he aprendido mucho sobre este mundo. Lamentablemente no todo es perfecto en esta vida y ahora estoy en crisis porque algo que me funciono bien una vez, ya no me funciono dos veces, es un dimmer para lamparas chinas y la primera vez me funciono bien hace tiempo y ahora despues de un tiempo lo desempolve para usarlo otra vez sin modificar absolutamente nada lo intento cargar y me sale
"Wire.send() ha sido renombrado a Wire.write() al cambiar el codigo como dice el error todo el codigo me empieza a fallar. Ahora no se que pasa, me dejo perplejo, las librerias estan instaladas el pc donde programe inicialmente es el mismo y arduino es el mismo. El que pueda ayudarme le agradecere enternamente,
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
byte ledcontrolv = 13;//led control
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
/
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second));
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour));
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
// Establece la fecha y el tiempo del ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0); //linea marcada por el IDE donde esta el error
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f);
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
byte ledazul = 5 , ledblanco = 6 , ventled = 53;//Luces
//Potencias
*/
float hmediodia= 17; // hora que establecemos como medio dia
float hluna=2; // numero de horas de luna
float hamplitud= 6; //horas de amplitud del dia, hmediodia-hamplitud es el momento de amanecer
float pwmmax = 200; //pwm maximo para los canales de luz
float mmediodia = hmediodia*60; //calcula el minuto del medio dia ejemplo 17*60
float mluna = hluna * 60; //minutos que dura la fase de luna
float mamplitud = hamplitud*60; //minutos que duara "amplitud"
float msubida = mamplitud / 2; //minutos que cuesta pasar de pwm=0 hasta pwm=pwmmax
float mfin = mmediodia + mamplitud; //minuto a partir del cual solo queda luz luna
float minicio = mmediodia - mamplitud; //minuto del dia en el que amanece
float pwmteorico = 0; //pwm teorico que calcula en cada minuto, puede ser mayor que 255
float pwm=0; //variable que en la que guardara pwm en cada minuto
float mactual=0; //variable en la que guardara en minuto actual del dia
float pwmluna=55; //pwm que establezcamos para periodo luna
void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);
/*
second = 00;
minute = 32;
hour = 14;
dayOfWeek = 5;
dayOfMonth = 12;
month = 8;
year = 11;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
*/
}
void loop()
{
luz();//
muestrahoraEnmonitor();
delay(1000);
}
void luz ()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
pwmteorico=0;
mactual = hour *60 + minute;
if(mactual > minicio && mactual <= mmediodia){
pwmteorico=(mactual-minicio)/msubida*pwmmax;
}
if(mactual>mmediodia && mactual <= mfin){
pwmteorico=((mfin-mactual)/msubida*pwmmax)+pwmluna;
}
if(mactual > mfin && mactual <= (mfin + mluna) ){
pwmteorico=pwmluna;
}
if(mactual+1440 < mfin+mluna){
pwmteorico=pwmluna;
}
if(pwmteorico>=pwmmax){
pwm = pwmmax;
}
else{
pwm=pwmteorico;
}
analogWrite(ledblanco,pwm);
}
void muestrahoraEnmonitor(){
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
Serial.print("20");
if (year < 10) Serial.print("0");
Serial.print(year, DEC);
Serial.print("/");
if (month < 10) Serial.print("0");
Serial.print(month, DEC);
Serial.print("/");
if (dayOfMonth < 10) Serial.print("0");
Serial.print(dayOfMonth, DEC);
Serial.print(" ");
if (hour < 10) Serial.print("0");
Serial.print(hour, DEC);
Serial.print(":");
if (minute < 10) Serial.print("0");
Serial.print(minute, DEC);
Serial.print(":");
if (second < 10) Serial.print("0");
Serial.print(second, DEC);
Serial.print(" Dia de la semana:");
// Serial.println(dayOfWeek, DEC);
// Esto pone nombre del dia
switch (dayOfWeek)
{
case 1:
Serial.println(" Lunes"); break;
case 2:
Serial.println(" Martes"); break;
case 3:
Serial.println(" Miercoles"); break;
case 4:
Serial.println(" Jueves"); break;
case 5:
Serial.println(" Viernes"); break;
case 6:
Serial.println(" Sabado"); break;
case 7:
Serial.println(" Domingo"); break;
}
}