This is the code i am using, every time I try to run it I get an error.
tried to fix it many times but I am stuck.
//musical alarm clock //
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
byte hour , minute , second ;
byte mm_load1_on,hh_load1_on;
byte mm_load1_off,hh_load1_off;
byte mm_wake,hh_wake;
byte n10,n1;
byte datedd,datemm,dateyy;
void setup()
{
Wire.begin();
Serial.begin(9600);
lcd.begin(16,2);
pinMode(8,INPUT);
DDRK = 0x00;
pinMode(12,INPUT); //Set waking time//
pinMode(9,OUTPUT);
digitalWrite(9,1);
pinMode(10,OUTPUT);
digitalWrite(10,1);
pinMode(11,OUTPUT);
digitalWrite(11,1);
lcd.clear();
lcd.print("MUSIC CLOCK");
lcd.setCursor(2,1);
lcd.print(" DAVID & DANIEL ");
while(digitalRead(8)==0);
delay(500);
date();
setupTime();
settimeload1();
set_time_wake();
lcd.clear();
lcd.print("clock:");
}
void loop()
{
readTime();
printTimeLcd();
testtimeloadl();
testwake();
delay(500);
}
//====================================
byte bcdToDec(byte val)
{
val=val/16*10 + val%16;
return (val);
//====================================
byte decToBcd (byte val)
{
val=val/10*16 + val%10;
}
return (val);
}
//====================================
void setupTime()
{
lcd.clear();
lcd.print("enter sec:");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
second = 10*n10 + n1;
delay(1000);
lcd.clear();
lcd.print("enter minute:");
while (digitalRead(8) 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
minute = 10*n10 + n1;
delay(1000);
lcd.clear();
lcd.print("enter hour:");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
hour = 10*n10 + n1;
delay(1000);
Wire.beginTransmission(0x68);
Wire.write(0x0);
Wire.write(decToBcd(second));
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.endTransmission();
}
//===========================
void readTime()
{
Wire.beginTransmission(0x68);
Wire.write(0x0);
Wire.endTransmission();
Wire.requestFrom(0x68,3);
if(Wire.available())
{
second = bcdToDec(Wire.read() );
minute = bcdToDec(Wire.read() );
hour = bcdToDec(Wire.read() & Ob111111);
}
//==============================
void printTimeSerial()
{
Serial.print(hour);
Serial.print(":");
Serial.print(minute);
Serial.print(":");
Serial.println(second);
}
//========================
void printTimeLcd()
{
lcd.setCursor(7,0);
lcd.print(hour/10);
lcd.print(hour%10);
lcd.print(":");
lcd.print(minute/10);
lcd.print(minute%10);
lcd.print(":");
lcd.print(second/10);
lcd.print(second%10);
lcd.setCursor(0,2);
lcd.print("Date : ");
lcd.print(datedd);
lcd.print("/");
lcd.print(datemm);
lcd.print("/");
lcd.print(dateyy);
}
byte scankey()
{
byte kod;
while(digitalRead(8) = 0);
kod = PINK;
byte num = kod & OxOf ;
while(digitalRead(8)==1);
switch(num)
{
case Ox0 : num = '1' ; break;
case 0x2 : num = '2' ; break;
case Ox1 : num = '3' ; break;
case 0x3 : num = 'A' ; break;
case 0x8 : num = '4' ; break;
case Oxa : num = '5' ; break;
case 0x9 : num = '6' ; break;
case Oxb : num = 'B' ; break;
case 0x4 : num = '7' ; break;
case 0x6 : num = '8' ; break;
case 0x5 : num = '9' ; break;
case 0x7 : num = 'C' ; break;
case Oxc : num = '*' ; break;
case Oxe : num = '0' ; break;
case Oxd : num = '#' ; break;
case Oxf : num = 'D' ; break;
}
return num;
}
//-----------------------------
void settimeload1()
{
lcd.clear();
lcd.print("mm load1 on:");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
mm_load1_on = 10*n10 + n1;
delay(1000);
lcd.clear();
lcd.print("hh load1 on:");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
nl=scankey();
lcd.write(n1);
n1=n1-0x30;
hh_load1on = 10*n10 + n1;
delay(1000);
lcd.cler();
lcd.print("mm loadl off:");
n10 scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
mm_loadl_off = 10*n10 + nh;
delay(1000);
lcd.clear();
lcd.print("hh loadl off:");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
hh_loadl_off = 10*n10 + n1;
delay(100);
}
//=====================
void testtimeloadl()
{
if((minute = mm loadl_on) && (hour = hh_loadl_on))
{
digitalWrite(9,0);
}
if((minute = mm_loadl_off) && (hour == hh_loadl off))
{
digitalWrite(9,1);
}
//=======================
void startisd1420()
{
digitalWrite(11,0);
delay(100);
digitalWrite(11,1);
}
//=======================
void test wake()
{
if((minute == MM wake)&& (hour== HH_wake))
{
startisd1420();
}
if (digitalRead(12) = 1)
{
MM_wake = -1;
HH_wake = -1;
}
//=========================
void settimewake()
{
lcd.clear();
lcd.print("min. wake up.");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
MM_wake = 10*-n10 + n1;
delay(1000);
lcd.clear();
lcd.print("hour wake up:");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
nl=n1-0x30;
HH_wake = 10*n10 + n1;
delay(1000);
}
void date()
lcd. clear ();
lcd.print ("ENTER DD: ");
while (digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
datedd = 10*n10 + n1;
delay(1000);
lcd.clear();
lcd.print("ENTER MM:");
while(digitalRead(8) == 0);
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(nl);
n1=n1-0x30;
datemm = 10*n10 + n1;
delay(1000);
lcd.clear();
lcd.print("ENTER YY:");
while(digitalRead(8) == 0)
n10 = scankey();
lcd.write(n10);
n10=n10-0x30;
n1=scankey();
lcd.write(n1);
n1=n1-0x30;
dateyy = 10*n10 + n1;
delay(1000);
}
````````````````````````````````````