There is no code in their for controlling a relay and this line: if(readString.indexOf("?relay4off") >0) Telling me your modication to a sketch that controls a device you don't even possess is "no good" is absurd. Your application does not involve a backlit lcd so you couldn't possibly run that code and tell me if it works or not. You cannot write code until you have done that. This code you are asking for is not a single line. If you cannot follow instructions, do it yourself. I'm trying to help you but I require your cooperation. I specifically said to rename the variables to something relevant to your application. I know that sketch works and others have used it as an example to create countdown or up timers. Here is the code that i have attempted to change, as you will see its not any good!!!įirst of all, I assumed you realized that the code posted in my last post was just a snippet from the sketch I uploaded previously (garagesensor). I thought I HAD mentioned this was for my grannies garden that she struggles to water now!!! smiley-wink We can only take it so far (normally, although we have been known to make exceptions when people cook up a really good song & dance story to get our sympathy, (My 95 yr old grandmother is all alone and needs etc etc etc.) I'm not going to do it for you because this forum exists to help you learn, not to do your work for you. Think about what you want to happen and change this code accordingly. This sketch turns OFF the backlight in 10 seconds so it starts with this: lcd.backlight() To something appropriate for your application. To a conditional that makes sense for your application.Ĭhange the name of the boolean blOn to something appropriate for your application.īlTime to something appropriate for your application. So you need to change the variable names and types to names that appropriate for your application and change the variable type to unsigned long and where you see the value "10000" in that sketch, it should have been defined as a constant instead of hardcoded as "10000", which is poor practice. How many milliseconds in 10 MINUTES ?ġ0 Min * 60 sec/min * 1000 mS /sec =600000.Ĭan this value be expressed with an 8-bit variable type (no)Ĭan this value be expressed with a 16-bit variable type (yes) You want 10 MINUTES.Īs you recall, I said DO THE MATH. You already know this sketch is written for a 10 SECOND delay. If (blOn = true & millis() - blTime > 10000) Backlight on - ten seconds - then off again If(readString.indexOf("?relay1off") >0)//checks for off If(readString.indexOf("?relay1on") >0)//checks for on Am i correct? Please take a look at my original code and let me know what you think. I assume that i need to put the timer code somewhere within the code for each button when pressedįor example somewhere in here? and then repeat for each button. Sorry to be a pain but pretty new to a lot of this. What i dont understand is what part of that script do i insert into mine? Obviously i want to continue to use my script as it has the webserver and relays all set up, i just want to extract the part that will turn each relay off after the period of time. I'm sure that this is pretty simple but I just need a hint or example that shows where in the sketch it should be written. Then if before the 10 minutes is UPI want to turn off the zone I can press the OFF button to stop it. The problem I am having is where to put timer code in my sketch so that when I turn on the zone it will stay on for a predetermined amount of time I.e. The running of the webserver is not a problwm, and it all works with 4 buttons that I press which operate each individual relay. For my project I want to keep things simple! A simple webserver that I can log into and control each zone by the press of a button. There are irrigation programs out there however they don't seem to compile without hundred as of errors and I haven't got the skills in programming to sort them all out. The four relays are basically going to control 4 solenoid valves that control 4 zones in my garden for watering purposes. Hi, thank you very much for your responses! OK to go into a little more detail.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |