hey guys, aside from breakbeam triggers and turning things on with the ambient light, this is my first project. feels like i'm getting close but i can't seem to figure out what i'm doing wrong
#include <DS3231.h>
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
const int blue= 13; //
const int green= 12;
const int yellow= 10;
const int white= 9;
const int red= 8;
const int blueSTATE = 0;
const int greenSTATE = 0;
const int yellowSTATE = 0;
const int whiteSTATE = 0;
const int redSTATE = 0;
#define time now = time_t(1740942204);
DS3231 Clock;
byte year;
byte month;
byte date;
byte dOW;
byte hour;
byte minute;
byte second;
byte temperature;
void getDateStuff(byte& year, byte& month, byte& date, byte& dOW,
byte& hour, byte& minute, byte& second, byte& temperature) {
// Call this if you notice something coming in on
// the serial port. The stuff coming in should be in
// the order YYMMDDwHHMMSS, with an 'x' at the end.
boolean gotString = false;
char inChar;
byte temp1, temp2;
char inString[20];
byte j=0;
while (!gotString) {
if (Serial.available()) {
inChar = Serial.read();
inString[j] = inChar;
j += 1;
if (inChar == 'x') {
gotString = true;
}
}
}
Serial.println(inString);
// Read year first
temp1 = (byte)inString[0] -48;
temp2 = (byte)inString[1] -48;
year = temp1*10 + temp2;
// now month
temp1 = (byte)inString[2] -48;
temp2 = (byte)inString[3] -48;
month = temp1*10 + temp2;
// now date
temp1 = (byte)inString[4] -48;
temp2 = (byte)inString[5] -48;
date = temp1*10 + temp2;
// now Day of Week
dOW = (byte)inString[6] - 48;
// now hour
temp1 = (byte)inString[7] -48;
temp2 = (byte)inString[8] -48;
hour = temp1*10 + temp2;
// now minute
temp1 = (byte)inString[9] -48;
temp2 = (byte)inString[10] -48;
minute = temp1*10 + temp2;
// now second
temp1 = (byte)inString[11] -48;
temp2 = (byte)inString[12] -48;
second = temp1*10 + temp2;
}
String comdata ="";
const int numdata[7] = {0},mark = 0;
const int buzz = 11;
void setup() {
pinMode(blue, INPUT_PULLUP);
pinMode(green, INPUT_PULLUP);
pinMode(yellow, INPUT_PULLUP);
pinMode(white, INPUT_PULLUP);
pinMode(red, INPUT_PULLUP);
pinMode(buzz, OUTPUT);
Wire.begin();
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16,2);
// Print a message to the LCD.
lcd.print(" DEEZ ");
lcd.setCursor(0,1); //Display position
lcd.print(" NUTZ");
delay(2000);
lcd.clear();
}
void loop() {
// If something is coming in on the serial line, it's
// a time correction so set the clock accordingly.
if (Serial.available());
getDateStuff(year, month, date, dOW, hour, minute, second, temperature);
Clock.setClockMode(false); // set to 24h
//setClockMode(true); // set to 12h
Clock.setYear(year);
Clock.setMonth(month);
Clock.setDate(date);
Clock.setDoW(dOW);
Clock.setHour(hour);
Clock.setMinute(minute);
Clock.setSecond(second);
}
void WriteDS3231();
{
Clock.setSecond(numdata[6]);
Clock.setMinute(numdata[5]);
Clock.setHour(numdata[4]);
Clock.setDoW(numdata[3]);
Clock.setDate(numdata[2]);
Clock.setMonth(numdata[1]);
Clock.setYear(numdata[0]);
}
void Print_time();
{
Clock.getTemperature();
lcd.setCursor(0, 0);
lcd.print("20"); // Show 20 Century
if (year>=10) // Display year
{
lcd.print(year,DEC);
}
else
{
lcd.print("0");
lcd.print(year,DEC);
}
lcd.print('-');
}
lcd.setCursor(5, 0);
if (month>=10) //Display month
{
lcd.print(month,DEC);
}
else
{
lcd.print("0");
lcd.print(month,DEC);
}
lcd.print('-');
lcd.setCursor(8, 0);
if (date>=10) // Display date
{
lcd.print(date,DEC);
}
else
{
lcd.print("0");
lcd.print(date,DEC);
}
lcd.setCursor(11, 0);
switch (dOW) // Display Week
{
case 1: // When Dow is equal to 1, execute the following statement
lcd.print("Mon");
break;
case 2: // When Dow is equal to 2, execute the following statement
lcd.print("Tue");
break;
case 3:
lcd.print("Wed");
break;
case 4:
lcd.print("Thu");
break;
case 5:
lcd.print("Fri");
break;
case 6:
lcd.print("Sat");
break;
case 7:
lcd.print("Sun");
break;
}
lcd.setCursor(0, 1);//Move the cursor to the second line.
if (hour>=10) //Display hours
{
lcd.print(hour,DEC);
}
else
{
lcd.print("0");
lcd.print(hour,DEC);
}
lcd.print(':');
lcd.setCursor(3, 1);
if (minute>=10) // Display minutes
{
lcd.print(minute,DEC);
}
else
{
lcd.print("0");
lcd.print(minute,DEC);
}
lcd.print(':');
lcd.setCursor(6, 1);
if (second>=10) //Display seconds
{
lcd.print(second,DEC);
}
else
{
lcd.print("0");
lcd.print(second,DEC);
}
lcd.setCursor(12, 1);
lcd.print(temperature); // Display temperature
lcd.write(0xdf); // Display temperature symbol
lcd.print("C");
}
if( hour == 7 && (minute == 30 || minute == 35)); //Comparing the current time with the Alarm time
{
tone(buzz, 50);
delay(50);
noTone(buzz);
delay(100);
lcd.clear();
lcd.print("WAKE THE");
lcd.setCursor(0,1);
lcd.print("FUCK UP");
delay(1000);
}
Now keep in mind it's incomplete, but kinda feels like i gotta fix this now before continuing.
my current serial output is;
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:129:3: error: expected unqualified-id before '{' token
{
^
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:143:4: error: expected unqualified-id before '{' token
{
^
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:160:5: error: 'lcd' does not name a type
lcd.setCursor(5, 0);
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:161:5: error: expected unqualified-id before 'if'
if (month>=10) //Display month
^~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:165:7: error: expected unqualified-id before 'else'
else
^~~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:170:3: error: 'lcd' does not name a type
lcd.print('-');
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:172:3: error: 'lcd' does not name a type
lcd.setCursor(8, 0);
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:173:5: error: expected unqualified-id before 'if'
if (date>=10) // Display date
^~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:177:7: error: expected unqualified-id before 'else'
else
^~~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:183:3: error: 'lcd' does not name a type
lcd.setCursor(11, 0);
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:184:5: error: expected unqualified-id before 'switch'
switch (dOW) // Display Week
^~~~~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:209:3: error: 'lcd' does not name a type
lcd.setCursor(0, 1);//Move the cursor to the second line.
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:210:5: error: expected unqualified-id before 'if'
if (hour>=10) //Display hours
^~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:214:7: error: expected unqualified-id before 'else'
else
^~~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:219:3: error: 'lcd' does not name a type
lcd.print(':');
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:221:3: error: 'lcd' does not name a type
lcd.setCursor(3, 1);
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:222:5: error: expected unqualified-id before 'if'
if (minute>=10) // Display minutes
^~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:226:7: error: expected unqualified-id before 'else'
else
^~~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:231:3: error: 'lcd' does not name a type
lcd.print(':');
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:233:3: error: 'lcd' does not name a type
lcd.setCursor(6, 1);
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:234:5: error: expected unqualified-id before 'if'
if (second>=10) //Display seconds
^~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:238:7: error: expected unqualified-id before 'else'
else
^~~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:244:7: error: 'lcd' does not name a type
lcd.setCursor(12, 1);
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:245:7: error: 'lcd' does not name a type
lcd.print(temperature); // Display temperature
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:246:7: error: 'lcd' does not name a type
lcd.write(0xdf); // Display temperature symbol
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:247:7: error: 'lcd' does not name a type
lcd.print("C");
^~~
C:\Users\Jucifer\Documents\Arduino\Alarm_clock_Project\Alarm_clock_Project.ino:248:7: error: expected declaration before '}' token
}
^
exit status 1
Compilation error: expected unqualified-id before '{' token
things left to be added
set alarm time (pin red)
stop button (pin white)
value + (yellow)
value - (green)
set time/next value (blue)
and i was thinking a tilt switch for snooze or just another button.