Hey Hey.
I made a code for a little alarm clock project, nothing much. But as I tried to upload it, it says:
exit status 1
expected initializer before 'void'
My Code looks like this:
// RTC
#include <Wire.h>
#define DS1307_ADDRESS 0x68;
// RTC
int hour;
int minute;
int second;
int active;
int weekDay;
int monthDay
#define BUZZER 3
#define US_In A0
#define US_Out 2
#define LCD_RS 6
#define LCD_RW 7
#define LCD_E 8
#define LCD_D4 9
#define LCD_D5 10
#define LCD_D6 11
#define LCD_D7 12
void setup() {
Wire.begin();
Serial.begin(9600);
pinMode(US_Out, OUTPUT);
};
void loop() {
// ULTRASONIC
long duration, distance;
digitalWrite(US_Out, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(US_Out, HIGH);
delayMicroseconds(10); // Added this line
digitalWrite(US_Out, LOW);
duration = pulseIn(US_In, HIGH);
distance = (duration/2) / 29.1;
if (distance<=80){
active = 0;
digitalWrite(BUZZER, LOW);
}
if (active==1) {
buzzer();
}
delay(10);
//ULTRASONIC
printDate();
}
// RTC
byte bcdToDec(byte val) {
// Convert binary coded decimal to normal decimal numbers
return ( (val/16*10) + (val%16) );
}
void printDate(){
// Reset the register pointer
Wire.beginTransmission(DS1307_ADDRESS);
byte zero = 0x00;
Wire.write(zero);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
int second = bcdToDec(Wire.read());
int minute = bcdToDec(Wire.read());
hour = bcdToDec(Wire.read() & 0b111111);
int weekDay = bcdToDec(Wire.read());
int monthDay = bcdToDec(Wire.read());
int month = bcdToDec(Wire.read());
int year = bcdToDec(Wire.read());
testForAlert();
Serial.print(month);
Serial.print("/");
Serial.print(monthDay);
Serial.print("/");
Serial.print(year);
Serial.print(" ");
Serial.print(hour);
Serial.print(":");
Serial.print(minute);
Serial.print(':');
Serial.println(second);
}
// RTC
// ALARM
int testForAlert() {
if (hour==7&&minute==0&&second==0&&!(weekDay==6||weekDay==7)) {
active=1;
};
return 0;
}
int buzzer() {
tone(BUZZER, 880);
delay(200);
digitalWrite(BUZZER, LOW);
delay(200);
}