muy buenas tengo un proyecto el :dispensador de comida para gato automatizado
pero con el programa tengo una duda que es.Que cosas le puedo cambiar para que vincule mi servomotorsg90 con el modulo de reloj DS1307 y asi el modulo este diciendole al servomotor en que momentos se debe accionar. De antemano les agradezco su ayuda
este es el código:
#include <Servo.h>
#include <DS3231.h>
#include <Wire.h>
char *horas[]={
"16:45",
"16:46",
"16:47",
"16:47",
"16:49"
};
long nhoras = (sizeof(horas)/sizeof(char *));
bool h12;
bool PM;
DS3231 Clock;
Servo servoMotor;
byte year, month, date, DoW, hour, minute, second;
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
delay(1000);
Clock.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*, ':', 0);*
_ m= getValue(horas*, ':', 1);_
_ hour = Clock.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]) : "";_
_}*_