Error compiling for board Arduino/Genuino Uno

Hi! Can you help me with my code? I attached a copy below

#include <DS3231.h>
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3',},
  {'4','5','6',},
  {'7','8','9',},
  {'*','0','#',}
};
byte rowPins[ROWS] = { 2, 3, 4, 5 };
byte colPins[COLS] = { 6, 7, 8, 9 };

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

I got these error messages

Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Guess\AppData\Local\Temp\cc7HRiFI.ltrans0.ltrans.o: In function `main':

C:\Users\Guess\Desktop\arduino-1.8.7\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup'

C:\Users\Guess\Desktop\arduino-1.8.7\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

Your help will be much appreciated.

Your program does not have a function named setup() in it, nor does it have a function named loop()

Look at any of the example programs to see how these two mandatory functions are used

Hi,
Can you post your complete code please.
Thanks for using code tags.. :slight_smile:

Tom.. :slight_smile:

Hi Tom, here are the codes.

#include <DS3231.h>
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3',},
  {'4','5','6',},
  {'7','8','9',},
  {'*','0','#',}
};
byte rowPins[ROWS] = { 2, 3, 4, 5 };
byte colPins[COLS] = { 6, 7, 8, 9 };

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

DS3231 rtc(A4, A5);
Servo servo_test; //initialize a servo object for the connected servo
LiquidCrystal lcd(A0, A1, A2, 11, 12, 13); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

int t1, t2, t3, t4, t5, t6;
boolean feed = true;
 char key;
 int r[6];

void setup()
 {
  servo_test.attach(10);   // attach the signal pin of servo to pin9 of arduino
  rtc.begin();
  lcd.begin(16,2);
  servo_test.write(55);
  Serial.begin(9600);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
 }

void loop() {
lcd.setCursor(0,0);
int buttonPress;
buttonPress = digitalRead(A3);

if (buttonPress==1)
 setFeedingTime();
 lcd.print("Time:  ");
 String t = "";

 t = rtc.getTimeStr();
 t1 = t.charAt(0)-48;
 t2 = t.charAt(1)-48;
 t3 = t.charAt(3)-48;
 t4 = t.charAt(4)-48;
 t5 = t.charAt(6)-48;
 t6 = t.charAt(7)-48;

 lcd.print(rtc.getTimeStr());
 lcd.setCursor(0,1);
 lcd.print("Date: ");
 lcd.print(rtc.getDateStr());

 if (t1==r[0] && t2==r[1] && t3==r[2] && t4==r[3]&& t5<1 && t6<3 && feed==true)
 {
  servo_test.write(100);                   //command to rotate the servo to the specified angle
   delay(400);  
  servo_test.write(55);
  feed=false;
 }
 }

void setFeedingTime()
{
  feed = true;
   int i=0;

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Set feeding Time");
  lcd.clear();
  lcd.print("HH:MM");
  lcd.setCursor(0,1);
  while(1){
    key = kpd.getKey();
    char j;

  if(key!=NO_KEY){
    lcd.setCursor(j,1);
    lcd.print(key);
    r[i] = key-48;
    i++;
    j++;

    if (j==2)
    {
      lcd.print(":"); j++;
    }
    delay(500);
  }

  if (key == 'D')
  {key=0; break; }
  }
}

Thanks for helping

DS3231 rtc(A4, A5);

What are the two pin numbers for ?

Have you looked at the examples with the library ?

Do you need to #include the Wire library ?

I am beginner so I don’t know much :confused: I attached two diagrams below.

I’m a college student, assigned for arduino project but I have no basic in programming.

Let me suggest a site to you. Have you heard of Hackster.io? You could look for answers for Arduino projects and problems there. Hope this helped.

Thank you for your suggestion!

nazdmiii:
I am beginner so I don’t know much :confused: I attached two diagrams below.

I’m a college student, assigned for arduino project but I have no basic in programming.

So, you have the DS3231 connected to pins A4 and A5 but these pins have a special function when used with the Wire library

Here is the start of an example DS3231 program that comes with the library

#include <DS3231.h>
#include <Wire.h>

DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;

void setup() {
	// Start the I2C interface
	Wire.begin();
	// Start the serial interface
	Serial.begin(9600);
}

Note the inclusion of the Wire library, the declaration of an object named Clock with no pins as parameters and the starting of the I2C interface to the RCT

Compare that with your program