Go Down

Topic: a (Read 1 time) previous topic - next topic

dyslexic

Dec 26, 2012, 12:37 pm Last Edit: Dec 27, 2012, 12:02 am by dyslexic Reason: 1
a

PaulS

Quote
but not turning on lights what am I doing wrong???


Code: [Select]
// functions to be called when an alarm triggers:
void Light1Alarm(){
  Serial.println("Alarm: - turn lights on");   
}

void Light1Alarmoff(){
  Serial.println("Alarm: - turn lights off");           
}

void Repeats(){
  Serial.println("15 second timer");         
}

Where did you tell the lights to turn on or off?

Arrch


have no clue got info from example from timealarm library


It's usually a good idea to learn what the code is doing particularly if it's not doing what you want it to do.

Arrch


well I'm a 50yr dyslexic the more I read the more confused I am getting after 2 months I;m ready to take a hammer to board, when I first looked into the arduino I choose it cause of support from community but have not got much support from anyone please help


Short of writing the code for you, what kind of support are you looking for?

You have code that doesn't something at timed intervals. You want it to do something else (turn on/off a light) at those same intervals. You haven't described what kind of "light" you are trying to turn on, how you're trying to turn it on, or how anything is hooked up. If you want help we need more information.

Arrch


I'm building a relay board that will turn stuff on/off with alarms


So start by getting it to turn on and off an LED. As long as the relay board is wired correctly, then turning the LED on an off can be used to simulate what will be done to the relay board; There are plenty of examples in the Arduino software that show you how to turn an LED on and off.

Arrch


that what I'm tryimg to do


Yet you don't have any digitalWrites in your code to tell the LED to turn on and off. The Serial.prints simply display messages on the Serial Monitor or other terminal program; they aren't going to change the state of an LED. If you look at the simple Blink example, you'll see that.

PaulS

Quote
and tried getting help with no luck

So, describe in English exactly what you want to happen at 6:00 AM (or 8:30 as the comment says) each day. Translating that into code is pretty simple.

If you want, for instance to turn pin 22 (light1) on, then add
Code: [Select]
  digitalWrite(light1, HIGH);
to Light1Alarm().

You add the same line to Light1AlarmOff(), except change HIGH to LOW.

It's not clear what Repeats() should do, so you need to help us out there.

It's also not clear whether you are setting the correct time in the RTC, or getting the correct time from it. Showing your serial output would help.

Arrch

It's hard to help you when you're not answering questions or providing us with anything more than

"I've tried a bunch of stuff and it doesn't work and nobody will help me."

PaulS

Quote
so this #include <DS1307RTC.h> and this   //sync clock
... dont tell you I'm using a RTC to set time to board

Yes, it does tell me (us) that you have an RTC. What it doesn't tell me (us) is whether the time is set on the RTC correctly, or that the RTC is indeed providing the correct time.

Please don't give up and wander off. But, remember we can only see what you post here. We can't see what is happening on your LCD, or on your serial monitor, or on your pins.

That we keep asking what is happening is not because we don't believe you. It is because we really can not see what is happening.

What we need to help you do is narrow down where the failure is. If you see "Setting pin 7 HIGH" followed by "Pin 7 is HIGH" on the serial monitor, and the only statement in between is digitalWrite(7, HIGH);, and you tell us that whatever is connected to pin 7 didn't turn on, we learn one thing. If it did turn on, we learn something else.

By process of elimination, we'll eventually understand what is happening/not happening. You are our eyes and ears, though.

UKHeliBob

Don't give up.

Let's take it slowly.  Do the lights on and lights off messages appear on the serial monitor as you would expect ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

UKHeliBob

I am confused by your replies.

Do you get the "Alarm: - turn lights on" and "Alarm: - turn lights off" messages on the serial monitor at the times that you would expect ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

PaulS

Quote
well you said to add digalwrite to alarm I have no clue where in code to put or the format ie: what bracket goes where the light1 pin is what I want to turn on the examples for timealarms DONT SHOW HOW SO EXAMPLES ARE WORTHLESS


Take a deep breath and try to relax a little. This is supposed to be a fun hobby.

void Light1Alarm()
{
 Serial.println("Alarm: - turn lights on");
 digitalWrite(light1, HIGH);
}

void Light1Alarmoff()
{
 Serial.println("Alarm: - turn lights off");          
 digitalWrite(light1, LOW);
}

Now, if this doesn't work, I'd suggest abandoning the TimeAlarms library. You have an RTC. On each pass through loop, you can figure out if it 6:00 AM. If so (now.minute() == 0 and now.hour == 6), turn the pin on. If you want to turn it off three minutes later (now.minute() == 3 and now.hour == 6), do that.

PaulS

#12
Dec 26, 2012, 07:33 pm Last Edit: Dec 26, 2012, 07:39 pm by PaulS Reason: 1
Quote
Do you get the "Alarm: - turn lights on" and "Alarm: - turn lights off" messages on the serial monitor at the times that you would expect ?

Quote
no


OK, then it is time to abandon the TimeAlarm library, and use a different approach.

Code: [Select]
  digitalClockDisplay(); 
  delay(1000);
  Alarm.delay(1000); // wait one second between clock display

This is actually causing a two second delay - one in the delay() function and one in the Alarm.delay() function. One of them needs to go - the plain delay(), actually.

PaulS

Quote
then it repeats

Lets be clear about this. What part of it repeats? If it is the whole thing, from "System Starting" on, then there is a real problem.

PaulS

Quote
update code to this still dont work maybe I should trash the arduino and look for something else

Did you learn to read in the Adult section of the library? I didn't think so.

You need to test one part of the code at a time. The issues with the TimeAlarm library have NOTHING to do with the PH sensors or switches, so get rid of that code. They have nothing to do with displaying the time on the LCD, so get rid of the LCD and the code to show the time on it.

Get the code down to something that sets an alarm at regular intervals - something more than once a day. Do nothing in the callback except print a message. Does that work? If it does, we can build from there. If not, we can dig into why not.

Go Up