LDR + DATE/TIME (URGENT)

Hi guys !
I need help!

I need a programming capable of performing a simple function :

When the light is out, or when there is no light, the system needs to identify the exact time and date and show the user.

And when the light is on the ldr, it waits until the light goes out. In other words, it is waiting, in other words, it does nothing.

The Arduino will be connected to the computer at all times.

The programming I use is the simple one of LDR :

//Sensor de luz

int ledPin = 7; //Led no pino 7
int ldrPin = 0; //LDR no pino analígico 8
int ldrValor = 0; //Valor lido do LDR
int ledPin2 = 6; //Led no pino 6
int ldrPin2 = 1; //LDR no pino analígico 8
int ldrValor2 = 0; //Valor lido do LDR

void setup() {
pinMode(ledPin,OUTPUT); //define a porta 7 como saída
pinMode(ledPin2,OUTPUT); //define a porta 7 como saída
Serial.begin(9600); //Inicia a comunicação serial
}

void loop() {
///ler o valor do LDR
ldrValor = analogRead(ldrPin); //O valor lido será entre 0 e 1023
ldrValor2 = analogRead(ldrPin2); //O valor lido será entre 0 e 1023

//se o valor lido for maior que 700, liga o led
if (ldrValor>= 700) digitalWrite(ledPin,HIGH);
// senão, apaga o led
else digitalWrite(ledPin,LOW);
//se o valor lido for maior que 700, liga o led
if (ldrValor2>= 700) digitalWrite(ledPin2,HIGH);
// senão, apaga o led
else digitalWrite(ledPin2,LOW);

//imprime o valor lido do LDR no monitor serial
Serial.println(ldrValor);
Serial.println(ldrValor2);
delay(100);
}

Explanation: When the value of "ldrValor" and "ldrValor2" is greater than or equal to 700, the Arduino must inform the time and date that this occurs.

If the value of "ldrValue" and "ldrValor2" is less than or equal to 700, the arduino will not do anything (standby).

Important, I am working with 8 ldr's(ldr,ldr2,ldr3,ldr4....), so the timestamp should be independent each.

So can anyone help me with programming?
I would be very grateful !!!!
Thank you!

The Arduino will be connected to the computer at all times.

Is that where it is supposed to get the date and time? Why? Why not have the application that would supply that information simply handle the notification that "It got dark" or "It got light"?

If the value of "ldrValue" and "ldrValor2" is less than or equal to 700, the arduino will not do anything (standby).

Clearly, you are wrong there. The Arduino is NOT doing nothing. It must be constantly checking each LDR pin to get the value, and determine of the value exceeds, or not, the tolerance.

Clearly, you are wrong there. The Arduino is NOT doing nothing. It must be constantly checking each LDR pin to get the value, and determine of the value exceeds, or not, the tolerance.

Exactly, I said silly.
You're completely right.

Is that where it is supposed to get the date and time? Why? Why not have the application that would supply that information simply handle the notification that "It got dark" or "It got light"?

I think some programming, calling libraries, can get Arduino to get the time and date..
Or is it not possible?
But I know absolutely nothing about programming, I hope you guys can help me.

tayanesilva:
But I know absolutely nothing about programming, I hope you guys can help me.

If you know nothing about programming, why are you doing this?

If you know nothing about programming, why are you doing this?

I bought the arduino a little while ago, and I'm learning to use it.
I'm using it with the Matlab tool, but I want to optimize an old work I did ... using a microcontroller.
Please do not judge me, I'm just trying to learn.. :confused:

I think some programming, calling libraries, can get Arduino to get the time and date..

From where? The Arduino does NOT know what time it is. If you add an RTC, the RTC knows the time and date, and can deliver that information to the Arduino.

From where? The Arduino does NOT know what time it is. If you add an RTC, the RTC knows the time and date, and can deliver that information to the Arduino.

Okay, I'll buy the RTC ..
With it could you tell me the correct programming to be used?

With it could you tell me the correct programming to be used?

Without knowing which RTC you are going to get? No.

Most RTCs have an Arduino library for them, with functions to get the current time/date, the current hour, the current minute, the current second, etc. And, examples.

tayanesilva:
Please do not judge me, I'm just trying to learn.. :confused:

Far be it from me to judge anyone, especially a beginner, since I rely on them to allow myself to Supersize a meal every so often. However, some people come here in hopes that we will do a homework assignment for them, and I was just trying to make sure you weren't one of them. We'd much prefer they do their assignments themselves.

Without knowing which RTC you are going to get? No.

I'll buy the Rtc Ds1307 I2c + Eeprom 24c32

Far be it from me to judge anyone, especially a beginner, since I rely on them to allow myself to Supersize a meal every so often. However, some people come here in hopes that we will do a homework assignment for them, and I was just trying to make sure you weren't one of them. We'd much prefer they do their assignments themselves.

Wow, I did not know!
I'm sorry, now I understand your point of view.
Arduino for me is a hobby, and I thought I could update a work I had done 6 years ago using it, and the best, improving.
The work I devised was super simple: a lamp post.
But now I want to record when these lamps go out, that's all.
And I'm getting to know more about this incredible component every day.
Again, I apologize, you are absolutely right.

I'll buy the Rtc Ds1307 I2c + Eeprom 24c32

I'd suggest the DS3231. It is about the same price and much more accurate.

I'd suggest the DS3231. It is about the same price and much more accurate.

Thanks,
I'll need anything else?

Arduino for me is a hobby

In that case, why is this (URGENT) ? And when is it due?

Pete

You could use the time library but you'd have to update the clock each time you opened serial port. Or you could use an RTC.
Or you could learn some Arduino to Python. Don't have all the specifics on these up to you to look into.

You could use the time library but you'd have to update the clock each time you opened serial port. Or you could use an RTC.
Or you could learn some Arduino to Python. Don't have all the specifics on these up to you to look into.

How would I use only the library?
Updating the clock will not be a problem as I just want to test and see if it works

In that case, why is this (URGENT) ? And when is it due?

Pete

Because I'm on vacation and bored, I want to do something productive ..
For the thousandth time, I'm redoing a very old job ...
If you have questions about Matlab, Fuzzy Controllers, PID, Ultra High Voltage ...
Do not hesitate to call me, I'M WILLING TO HELP!
I'm new to Arduino, and what I'm asking for is a simple help.

PaulS:
Is that where it is supposed to get the date and time? Why? Why not have the application that would supply that information simply handle the notification that "It got dark" or "It got light"?

PaulS is asking the best question here. You don't need to get a RTC chip. If the Arduino is always connected to a PC, then that PC already knows what the time is, whatever program you are running on the PC (MatLab, or your own Basic or C# program or anything....). Just send the light/dark info to the PC all the time, and let the PC decide what the time is when the light comes on.

and let the PC decide what the time is when the light comes on.

More like "what time the PC learned that the light came on". For most purposes, with non-blocking code on both ends, the difference is minor and consistent.

PaulS is asking the best question here. You don't need to get a RTC chip. If the Arduino is always connected to a PC, then that PC already knows what the time is, whatever program you are running on the PC (MatLab, or your own Basic or C# program or anything....). Just send the light/dark info to the PC all the time, and let the PC decide what the time is when the light comes on.

Alright, the Arduino will be 24 hours and 7 days a week connected to the PC !!
So you will not need the RTC?
I'm confused now