Hola a todos:
Este es mi primer proyecto con arduino en el cual quiero simular un reloj convencional donde se encienda un led por hora y estos se mantengan activos hasta las que sean las 12:59 (tanto en am y pm) donde estos se apaguen y luego comience el ciclo nuevamente cuando sean las 1 o 13hrs.
Estoy utilizando un RTC y la librería TimeAlarms.
Tengo un problema al llamar la función de apagado de los leds, donde me dice que no he ingresado correctamente la función de alarma de apagado. He revisado el código y no logro encontrar el o los errores. Les adjunto el código de programación y de error.
Desde ya muchas gracias.
// Conexion i2C :Arduino UNO SCL-> A5 SDA->A4 VCC->5V GND->GND
// Conexion RTC :Arduino UNO GND->GND VCC->5V SCL-> SCL SDA->SDA los dos pines despues del ...12,13,GND,AREF,SDA,SCL
// Conexion Rele:Arduino UNO GND->GND VCC->5V IN->7
// NOTA: se debe cargar dos veces este programa 1. Con la linea RTC.adjust(DateTime(__DATE__, __TIME__));
// 2. Sin esa linea
#include <Wire.h>
#include "RTClib.h"
#include <TimeLib.h>
#include <TimeAlarms.h>
RTC_DS3231 RTC;
int misleds[12] = {13,2,3,4,5,6,7,8,9,10,11,12};
int apagoleds[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
////////////////////// void setup() //////////////////////////
void setup() {
Wire.begin();
Serial.begin(9600);
RTC.begin(); // Inicia la comunicaci¢n con el RTC
//RTC.adjust(DateTime(__DATE__, __TIME__)); // Lee la fecha y hora del PC (Solo en la primera carga)
// el anterior se usa solo en la configuracion inicial luego se pone como comentario
// y se vuelve a cargar el programa sin esa linea.
//////// salidas /////////
pinMode(13,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
for(int i=0 ;i<12; i++)
{
pinMode(misleds[i],OUTPUT);
}
/////////////// alarmas ///////////////
Alarm.alarmRepeat(1, 0, 0, PrendoLed13); //enciendehora1
Alarm.alarmRepeat(2, 0, 0, PrendoLed2);
Alarm.alarmRepeat(3, 0, 0, PrendoLed3);
Alarm.alarmRepeat(4, 0, 0, PrendoLed4);
Alarm.alarmRepeat(5, 0, 0, PrendoLed5);
Alarm.alarmRepeat(6, 0, 0, PrendoLed6);
Alarm.alarmRepeat(7, 0, 0, PrendoLed7);
Alarm.alarmRepeat(8, 0, 0, PrendoLed8);
Alarm.alarmRepeat(9, 0, 0, PrendoLed9);
Alarm.alarmRepeat(10, 0, 0, PrendoLed10);
Alarm.alarmRepeat(11, 0, 0, PrendoLed11);
Alarm.alarmRepeat(12, 0, 0, PrendoLed12);
//
Alarm.alarmRepeat(13, 0, 0, PrendoLed13);
Alarm.alarmRepeat(14, 0, 0, PrendoLed2);
Alarm.alarmRepeat(15, 0, 0, PrendoLed3);
Alarm.alarmRepeat(16, 0, 0, PrendoLed4);
Alarm.alarmRepeat(17, 0, 0, PrendoLed5);
Alarm.alarmRepeat(18, 0, 0, PrendoLed6);
Alarm.alarmRepeat(19, 0, 0, PrendoLed7);
Alarm.alarmRepeat(20, 0, 0, PrendoLed8);
Alarm.alarmRepeat(21, 0, 0, PrendoLed9);
Alarm.alarmRepeat(22, 0, 0, PrendoLed10);
Alarm.alarmRepeat(23, 0, 0, PrendoLed11);
Alarm.alarmRepeat(00, 0, 0, PrendoLed12);
//
/////alarma de apagado/////
Alarm.alarmRepeat(00,59,0, ApagoLed(misleds[i]);
Alarm.alarmRepeat(12,59,0, ApagoLed(misleds[i]);
}
////////////////////// void loop () ///////////////////
void loop () {
digitalClockDisplay();
Alarm.delay(1000); // esperar 1 segundo entre displays
DateTime now = RTC.now(); // Obtiene la fecha y hora del RTC
}
/////// callback alarmas //////
void PrendoLed13(){ ///1am
Serial.println ("PrendoLed13");
digitalWrite (13,HIGH);
}
void PrendoLed2(){ ///2am
Serial.println ("PrendoLed2");
digitalWrite (2,HIGH);
}
void PrendoLed3(){ ///3am
Serial.println ("prendoLed3");
digitalWrite (3,HIGH);
}
void PrendoLed4(){ ///4am
Serial.println ("PrendoLed4");
digitalWrite (4,HIGH);
}
void PrendoLed5()
{ ///5am
Serial.println ("PrendoLed5");
digitalWrite (5,HIGH);
}
void PrendoLed6(){ ///6am
Serial.println ("PrendoLed6");
digitalWrite (6,HIGH);
}
void PrendoLed7(){ ///7am
Serial.println ("PrendoLed7");
digitalWrite (7,HIGH);
}
void PrendoLed8(){ ///8am
Serial.println ("PrendoLed8");
digitalWrite (8,HIGH);
}
void PrendoLed9(){ ///9am
Serial.println ("PrendoLed9");
digitalWrite (9,HIGH);
}
void PrendoLed10 (){ ///10am
Serial.println ("PrendoLed10");
digitalWrite (10,HIGH);
}
void PrendoLed11(){ ///11am
Serial.println ("PrendoLed11");
digitalWrite (11,HIGH);
}
void PrendoLed12(){ ///12am
Serial.println ("PrendoLed12");
digitalWrite (12,HIGH);
}
///
void ApagoLed(misled[i]){
for(int i=0 ;i<12; i++)
{
digitalWrite (misleds[i],apagoleds[i]);
Serial.println ("ApagoLeds");}
}
//////// PM ///////
void PrendoLed13(){ ///1pm
Serial.println ("PrendoLed13");
digitalWrite (13,HIGH);
}
void PrendoLed2(){ ///2pm
Serial.println ("PrendoLed2");
digitalWrite (2,HIGH);
}
void PrendoLed3(){ ///3pm
Serial.println ("PrendoLed3");
digitalWrite (3,HIGH);
}
void PrendoLed4(){ ///4pm
Serial.println ("PrendoLed4");
digitalWrite (4,HIGH);
}
void PrendoLed5(){ ///5pm
Serial.println ("PrendoLed5");
digitalWrite (5,HIGH);
}
void PrendoLed6(){ ///6pm
Serial.println ("PrendoLed6");
digitalWrite (6,HIGH);
}
void PrendoLed7(){ ///7pm
Serial.println ("PrendoLed7");
digitalWrite (7,HIGH);
}
void PrendoLed8 (){ ///8pm
Serial.println ("PrendoLed8");
digitalWrite (8,HIGH);
}
void PrendoLed9(){ ///9pm
Serial.println ("PrendoLed9");
digitalWrite (9,HIGH);
}
void PrendoLed10(){ ///10pm
Serial.println ("PrendoLed10")
digitalWrite (10,HIGH)
}
void PrendoLed11 (){ ///11pm
Serial.println ("PrendoLed11");
digitalWrite (11,HIGH);
}
void PrendoLed12(){ ///12pm
Serial.println ("PrendoLed12");
digitalWrite (12,HIGH);
}
///
void ApagoLed(misled[i]){
for(int i=0 ;i<12; i++)
{
digitalWrite (misleds[i],apagoleds[i]);
Serial.println ("ApagoLeds");}
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
Aquí les dejo el error:
pruebareloj:135:15: error: variable or field 'ApagoLed' declared void
void ApagoLed(misled[i]){
^
pruebareloj:135:15: error: 'misled' was not declared in this scope
pruebareloj:135:22: error: 'i' was not declared in this scope
void ApagoLed(misled[i]){
^
C:UsersWladimirDocumentsArduinopruebarelojpruebareloj.ino: In function 'void setup()':
pruebareloj:72:47: error: 'i' was not declared in this scope
Alarm.alarmRepeat(00,59,0, ApagoLed(misleds[i]);
^
pruebareloj:72:49: error: 'ApagoLed' was not declared in this scope
Alarm.alarmRepeat(00,59,0, ApagoLed(misleds[i]);
^
C:UsersWladimirDocumentsArduinopruebarelojpruebareloj.ino: At global scope:
pruebareloj:135:16: error: variable or field 'ApagoLed' declared void
void ApagoLed(misled[i]){
^
pruebareloj:135:16: error: 'misled' was not declared in this scope
pruebareloj:135:23: error: 'i' was not declared in this scope
void ApagoLed(misled[i]){
^
exit status 1
variable or field 'ApagoLed' declared void