Analog pins not being declared with rtc, And iostream and ctime error

void setup() {
#include
#include
#include
pinMode(a6, OUTPUT);
pinMode(a7,OUTPUT);
pinMode(d5, OUTPUT);
//I dont know the exact pins fo the module clock so I mad eup one called
using namespace std;

int main()

int sec_prev=0;
while (1)
{
int seconds, minutes, hours;
string str;

time_t total_seconds=time(0);
struct tm* ct=localtime(&total_seconds);

seconds=ct->tm_sec;
minutes=ct->tm_min;
hours=ct->tm_hour;

if(hours=15)
str="Ready"

}
digitalWrite(13, HIGH));
delay(180000);

}
else
str="AM";

if(seconds==sec_prev+1 || (sec_prev==59 && seconds==0))
{
  system("CLS");
  cout<< (hours<10?"0":"") << hourse <<":" << (minutes<10?"0":"") << ":" << (seconds<10?"0":"") << seconds << " " << str <<endl;
}

I am struggling to get my analog pins to upload correctly. I declared both pins (a6, and a7) as outputs in the void setup however I keep getting the same error message. Also, it is saying: "iostream: No such file or directory" and the same thing for ctime.

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

There are a LOT of problems with your sketch.

For a start, I'd need to know what model of Ardiuno you have.

Your sketch is a mess. You cannot type a bunch of random text into the editor and expect it to compile, and/or do anything useful.

Start with the one below and go from there.

void setup()
{
}

void loop()
{
}

Arduino nano, and I fixed some of the void setup and void loop problems however am still having trouble with everything else.

Maybe it's time to post your current sketch.

Your 'a6' and 'a7' problems are partly because the analog input pins are 'A6' and 'A7' and partly because those two pins don't have digital I/O capability. They can only do analogRead() so you can't use pinMode(), digitalRead(), digitalWrite() or analogWrite() on them.

Your 'd5' problem is that the pin is called '5', not 'd5' or 'D5'.

The iostream library is not included. I would get used to using Serial for output.

The Arduino Nano doesn't have an operating system to supply time information. If you need clock time you would generally add a Real-Time Clock (RTC) chip and libraries.

You should be defining "void loop()" instead of "main()" and "while (1)".

There is no operating system so you can't use "system()" to run OS command lines.

the Arduino nano is connected to the rtc (which I forgot to mention) through pins A6 and A7 and I already have the correct rtc libraries installed for my specific rtc model so why wouldn't system () work. Also, what should I replace" #include<iostream, #include<ctime, #include<cstdlib" with using serial? And I apologize for not posting the current sketch so here it is:

void setup() {
#include
#include
#include
analogRead(A6, OUTPUT);
analogRead(A7,OUTPUT);
pinMode(5, OUTPUT);
//I dont know the exact pins fo the module clock so I mad eup one called
using namespace std;
}
void loop(){

int sec_prev=0;

{
int seconds, minutes, hours;
string str;

time_t total_seconds=time(0);
struct tm* ct=localtime(&total_seconds);

seconds=ct->tm_sec;
minutes=ct->tm_min;
hours=ct->tm_hour;

if(hours=15)
str="Ready"

}
digitalWrite(13, HIGH));
delay(180000);

}
else
str="AM";

if(seconds==sec_prev+1 || (sec_prev==59 && seconds==0))
{
  system("CLS");
  cout<< (hours<10?"0":"") << hourse <<":" << (minutes<10?"0":"") << ":" << (seconds<10?"0":"") << seconds << " " << str <<endl;
}

}

That's never going to work unless you have an RTC with two ANALOG outputs. None that I know of do. What type of RTC do you have? I recommend the DS3231 for accuracy. That will connect to the Wire/I2C/TWI bus which shares pins A4 and A5 on the Arduino UNO and Nano. It uses A4 and A5 for the specialized interface hardware, not as analog inputs, so you can't substitute any other pins.

You will need a library (or two) for the RTC. Pick one that supports your chip and try some of the example sketches that come with the library.

Here is your sketch with some of the problems removed.

void setup() {
  Serial.begin(115200);
  delay(200);

  pinMode(5, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
}

int sec_prev = 0;  // Global Variable

void loop() {
  int seconds, minutes, hours;
  time_t total_seconds = time(0);
  struct tm* ct = localtime(&total_seconds);

  seconds = ct->tm_sec;
  minutes = ct->tm_min;
  hours = ct->tm_hour;

  // Turn on the light from 3pm to 4pm
  if (hours == 15) {
    digitalWrite(LED_BUILTIN, HIGH));
  }
else
 digitalWrite(LED_BUILTIN, LOW));

  if (seconds != sec_prev) {
    sec_prev = seconds;

    if (hours < 10)
      Serial.print('0');
    Serial.print(hours);
    Serial.print(':');
    if (minutes < 10)
      Serial.print('0');
    Serial.print(minutes);
    Serial.print(':');
    if (seconds < 10)
      Serial.print('0');
    Serial.println(seconds);
  }
}

I do have the DS3231 and the libraires for it installed and in your fixed version of it, does the clock module automatically communicate to the Arduino through analog pins A4 and A5 becuase I thought you had to clarify which pins you are communicating with and in your code, you never declared A4 and A5 as outputs and when I plugged in your code it said time_t was not declared in the scope