Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

alarm clock

5 posts / 0 new
Last post
MOUHSSINE
MOUHSSINE's picture
Offline
Last seen: 4 months 1 week ago
Joined: 15/12/2017 - 20:00
alarm clock

MOUHSSINE
MOUHSSINE's picture
Offline
Last seen: 4 months 1 week ago
Joined: 15/12/2017 - 20:00
alarm clock

hello,

i need help please to fix this errors in this code of an alarm clock.

 

#include <LiquidCrystal_I2C.h>
#include <Time.h>
#include <LiquidCrystal.h> 
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <Wire.h>
#include <AnalogButtons.h>
#include <EEPROM.h>
 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
String Jour[]={"Dim ", "Lun ", "Mar ", "Mer ", "Jeu ", "Ven ", "Sam "};
byte memo=0, hautbas=0, droite=0, HrAlarm=0, MinAlarm=0, ConfigAlarm=0;
byte CurCol[6]={6,9,14,5,8,11};
byte CurColAlarm[10]={1,4,7,9,10,11,12,13,14,15};
tmElements_t tmps;
boolean actualiser=0;
 
 
AnalogButtons pressBouton(A0, 10, &selectBouton);
Button b1=Button( 1,0  ,10 );
Button b2=Button( 2,500,520);
Button b3=Button( 3,670,690);
 
void selectBouton(int id, boolean longApui) {
switch (id) {
case 1: 
if (hautbas==0) {
switch (droite) {
case 0:
hautbas+=1;
HrAlarm=EEPROM.read(hautbas*3);
HrAlarm=EEPROM.read(hautbas*3+1);
HrAlarm=EEPROM.read(hautbas*3+2);
actualiser=1;
break;
case 1:
tmps.Day+=1;
if( tmps.Day >31) tmps.Day=1;
memo -=1;
break;
case 2:
tmps.Month+=1;
if(tmps.Month >12) tmps.Month=1;
memo -=1;
break;
case 3:
tmps.Year+=1;
memo -=1;
break;
case 4:
tmps.Hour+=1;
if(tmps.Hour >23) tmps.Hour=0;
memo -=1;
break;
case 5:
tmps.Minute+=1;
if( tmps.Minute >59) tmps.Minute=0;
memo -=1;
break;
case 6:
tmps.Second+=1;
if(tmps.Second >59) tmps.Second=0;
memo -=1;
break;                                                                                                                                                                                                                                                                                                                                                                                                                                        
}
}else {
switch (droite){
case 0:
if(hautbas==30){
hautbas=0; 
}else{
hautbas+=1;
HrAlarm=EEPROM.read(hautbas*3);
MinAlarm=EEPROM.read(hautbas*3+1);
ConfigAlarm=EEPROM.read(hautbas*3+2); 
}
break;
case 1:
HrAlarm+=1;
if(HrAlarm >23) HrAlarm =0;
break;
case 2:
MinAlarm+=1;
if(MinAlarm >59) MinAlarm=0;
break;
default:
bitWrite(ConfigAlarm, droite-2, !bitRead(ConfigAlarm, droite-2));
break;
}
actualiser=1;
}
 
 
case 2:
if(hautbas==0){
switch (droite){
case 0:
hautbas=30;
HrAlarm=EEPROM.read(hautbas*3);
MinAlarm=EEPROM.read(hautbas*3+1);
ConfigAlarm=EEPROM.read(hautbas*3+2);
actualiser=1;
break;
case 1:
tmps.Day-=1;
if (tmps.Day <1) tmps.Day=31;
memo -=1;
break;
case 2:
tmps.Month-=1;
if(tmps.Month <1) tmps.Month=12;
memo -=1;
break;
case 3:
tmps.Year-=1;
if(tmps.Year <47) tmps.Year=47;
memo -=1;
break;
case 4:
tmps.Hour-=1;
if(tmps.Hour >23) tmps.Hour=23;
memo -=1;
break;
case 5:
tmps.Minute-=1;
if(tmps.Minute >59) tmps.Minute=59;
memo -=1;
break;
case 6:
tmps.Second-=1;
if(tmps.Second >59) tmps.Second=59;
memo =tmps.Second-1;
break;
}
}else{
switch(droite){
case 0:
hautbas-=1;
HrAlarm=EEPROM.read(hautbas*3);
MinAlarm=EEPROM.read(hautbas*3+1);
ConfigAlarm=EEPROM.read(hautbas*3+2);
break;
case 1:
HrAlarm-=1;
if(HrAlarm >23) HrAlarm=23;
break;
case 2:
MinAlarm-=1;
if(MinAlarm >59) MinAlarm=59;
break;
default:
bitWrite(ConfigAlarm, droite-2, !bitRead(ConfigAlarm, droite-2));
break;
}
actualiser=1;
}
break;
 
case 3: 
droite +=1;
if (hautbas==0 && droite >6){
RTC.write(tmps);
setSyncProvider(RTC.get);
droite=0;
}
if(droite>9){
EEPROM.write(hautbas*3, HrAlarm);
EEPROM.write(hautbas*3+1, MinAlarm);
EEPROM.write(hautbas*3+2, ConfigAlarm);
droite=0;
}
actualiser=1;
break;
}
// 
void affichage(){   
if(hautbas==0){
if(droite==0) breakTime(now(), tmps);
if(memo!=tmps.Second){
lcd.setCursor(0,0);
lcd.print(" ");
lcd.print(Jour[tmps.Wday-1]);
aff(tmps.Day, "/");
aff(tmps.Month, "/");
aff(tmYearToCalendar(tmps.Year), " ");
lcd.setCursor(0,1);
lcd.print("    ");
aff(tmps.Hour, ":");
aff(tmps.Minute, ":");
aff(tmps.Second, ":");
memo =tmps.Second;
}
if(droite==0){
lcd.noBlink();
}else{
lcd.setCursor(CurCol[droite-1], droite/4);
lcd.blink();
}
}else {
if(actualiser){
lcd.setCursor(0,0);
lcd.print("AL Heure DLMMJVD");
lcd.setCursor(0,1);
aff(hautbas," ");
aff(HrALarm,":");
aff(MinALarm," ");
for(byte j=1; j<8; j++) lcd.print(bitRead(ConfigAlarm, j));
lcd.setCursor(CurColAlarm[droite],1);
lcd.blink();
actualiser=0;
}
}
}
//
void aff (int nbr, String chaine){  
if(nbr<10) lcd.print ("0");
lcd.print(String(nbr)+chaine);
}
//
void setup(){ 
pinMode(LED_BUILTIN, OUTPUT);
lcd.begin(16,2);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklightPin(HIGHT);
setSyncProvider(RTC.get);
 
pressBouton.addButton(b1);
pressBouton.addButton(b2);
pressBouton.addButton(b3);
 
void loop() {
affichage();
pressBouton.checkButtons();
 
if( !second()){
for(byte k=1; k<31;k++){
byte HrA=EEPROM.read(k*3);
byte MinA=EEPROM.read(k*3+1);
byte ConfigA=EEPROM.read(k*3+2);
if(hour()==HrA && minute()==MinA && bitRead( ConfigA, weekday())==1){
digitalWrite(LED_BUILTIN, 1); //or HIGH
break;
}
}
}
if(second() >10 && digitalRead(LED_BUILTIN)) digitalWrite(LED_BUILTIN, LOW); // or LOW
}
Hari Prasaath K
Hari Prasaath K's picture
Offline
Last seen: 13 hours 47 min ago
Joined: 20/01/2015 - 23:56
Error in Code

Hi,

Specify what error you are getting the above code.

MOUHSSINE
MOUHSSINE's picture
Offline
Last seen: 4 months 1 week ago
Joined: 15/12/2017 - 20:00
C:\Users\ehmouhssine\Desktop
C:\Users\ehmouhssine\Desktop\my arduino projects\sirene_scolaire\sirene_scolaire.ino: In function 'void setup()':
 
sirene_scolaire:436:5: error: 'class LiquidCrystal' has no member named 'setBacklightPin'
 
sirene_scolaire:436:23: error: 'POSITIVE' was not declared in this scope
 
sirene_scolaire:438:5: error: 'class LiquidCrystal' has no member named 'setBacklightPin'
 
sirene_scolaire:438:21: error: 'HIGHT' was not declared in this scope
 
sirene_scolaire:444:13: error: 'class AnalogButtons' has no member named 'addButton'
 
sirene_scolaire:446:13: error: 'class AnalogButtons' has no member named 'addButton'
 
sirene_scolaire:448:13: error: 'class AnalogButtons' has no member named 'addButton'
 
C:\Users\ehmouhssine\Desktop\my arduino projects\sirene_scolaire\sirene_scolaire.ino: In function 'void loop()':
 
sirene_scolaire:460:13: error: 'class AnalogButtons' has no member named 'checkButtons'
 
exit status 1
'class LiquidCrystal' has no member named 'setBacklightPin'
Ashutosh Bhatt
Ashutosh Bhatt's picture
Offline
Last seen: 1 week 4 days ago
Joined: 21/12/2010 - 15:59
seems like you just have copy

seems like you just have copy-paste the code from somewhere

withouth knowing anything about it

try to read and understand the code first as per your hardware and circuit operation