tengo una duda. estoy haciendo un dispensador de comida para gatos con servomotor y un modulo DS1307
y necesito saber que le puedo cambiar al codigo ya que me envia estos errores:
-error: 'RTC_DS1307' does not name a type
-warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings].
Soy novato en esto. de antemano agradezco su ayuda
#include <DS1307RTC.h>
#include <Servo.h>
#include <Wire.h>
#include <Time.h>
#include <TimeLib.h>
char *horas[]={
"8:30",
"8:35",
"8:40",
"16:47",
"16:49"
};
long nhoras = (sizeof(horas)/sizeof(char *));
bool h12;
bool PM;
RTC_DS1307 RTC;
Servo servoMotor;
byte year, month, date, DoW, hour, minute, second;
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
delay(1000);
RTC_DS1307 RTC.getTime(year, month, date, DoW, hour, minute, second);
if(deboGirar()==1)
girar();
}
void girar(){
servoMotor.attach(9);
int i;
for (i=0;i<4;i++){
servoMotor.write(0);
delay(500);
servoMotor.write(90);
delay(500);
}
servoMotor.detach();
}
int deboGirar(){
String h = "";
String m = "";
for(int i=0;i<nhoras;i++){
h= getValue(horas[i], ':', 0);
m= getValue(horas[i], ':', 1);
hour = RTC_DS1307 RTC.getHour(h12, PM);
if(int(hour)==atoi(h.c_str()) && int(minute)==atoi(m.c_str()) && int(second)==0)
return 1;
}
return 0;
}
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = { 0, -1 };
int maxIndex = data.length() - 1;
for (int i = 0; i <= maxIndex && found <= index; i++) {
if (data.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}