# Garden Irrigator

#### The bear

##### Senior Member
Hello,
Problem, using 'Toggle'.
Toggle flashes a Led, to indicate water flow. When power (12v) is removed, Led has a 50 50 chance of being OFF, I would like 100%
Code:
``````;IRRIGATION using Buzby timer v1.0a 12.06.19  (Thank you Buzby, Desperate Dans cat).
#picaxe 08m2 ;274 Bytes Toggle C.1 = 12v present
#No_data    ;1 HR delay, ON for 1 Hr, OFF for 2 Hrs, ON  for 1 HR
;Resets after 24 Hrs

Sertxd("IRRIGATION using Buzby timer v1.0a 12.06.19",13,10)
Symbol minutes = w2
Symbol hours   = w3
Symbol valve  = C.2 'was C.4
Symbol valveSupplyLed = C.1
Symbol valvepower = pinC.3
' Start of code
minutes  = 0
hours  = 0
Do
Do ' Hours loop
time = 0     ' Reset in-built seconds counter
Do ' Minutes loop
;----------------------------------------------------
If valvepower = 0 Then '+12v present was = 1
Toggle valveSupplyLed 'Flash Led
Endif
;------------------------------------------------
Pause 1000
;Sertxd (#hours,":",#minutes,":",#time,Cr,Lf)  'Com'd out when in use.
Loop Until time > 59 ' *** Should be 59 for one minute
minutes = minutes + 1
Loop Until minutes > 59 ' *** Should be 59 for one hour
hours = hours + 1
minutes = 0
If hours = 1 Then
Sertxd ("Valve operated ON",Cr,Lf)
High valve        ' Operate Valve ON for 1 Hour
Endif
If hours = 2  Then  ;was 24 ( 12 hrs, Spot on) No Sertxd line 20
Sertxd ("Valve operated OFF",Cr,Lf)
Low valve 'Valve OFF
Endif
If hours = 4  Then  ;was 24 ( 12 hrs, Spot on) No Sertxd line 20
Sertxd ("Valve operated ON",Cr,Lf)
High valve 'Valve OFF
Endif
If hours = 5  Then  ;was 24 ( 12 hrs, Spot on) No Sertxd line 20
Sertxd ("Valve operated OFF",Cr,Lf)
Low valve 'Valve OFF
Endif
If hours = 24  Then  ;was 24 ( 12 hrs, Spot on) No Sertxd line 20

Reset 'Every 24 Hours
Endif
Loop``````

#### Attachments

• 49.5 KB Views: 32
Last edited by a moderator:

#### lbenson

##### Senior Member
Why not (if I understand what you're asking--blink if 12V present, OFF if not present)
Code:
``````If valvepower = 1 Then '+12v present was = 1
toggle valveSupplyLed 'Flash Led
Else
low valveSupplyLed
Endif``````
Perhaps you also want a "low valveSupplyLed" after "low valve"

If your code had indentation, you can preserve it by going back and enclosing it between the [ code] and [ /code] tags (without the spaces). That would make your code structure easier to understand.

Last edited:

#### The bear

##### Senior Member
@ Ibenson,
I selected all, then clicked 'for forum' then pasted into code/ code. Will try harder.

My problem, When the power is removed from the water valve, sometimes the toggled Led is off, equally sometimes is on, not toggling, but on.
bear..

#### Buzby

##### Senior Member
I selected all, then clicked 'for forum' then pasted into code/ code. ...
I had the same problem with 'Paste for Forum', it displayed as formatting text, not coloured text.

So I just did a normal copy, then pasted between the code tags. Came out B&W, but with indents as expected.

I'll do some playing in the sandbox, might find a solution.

Cheers,

Buzby

EDIT : Sorted ! See the sandbox.

Last edited:

#### The bear

##### Senior Member
Corrected circuit. pinC.3 feed.
Apologies for any confusion.
bear..

#### lbenson

##### Senior Member
With the new drawing, is C.3 ever low when the 12V supply is present?

#### hippy

##### Technical Support
Staff member
I hope you won't mind the intervention but I took the liberty of editing your code tags for you.

[code]...[/code] is what one usually wants, [code=rich]...[/code] if it includes syntax colouring commands.

Using [icode]...[/icode] is what puts boxes around things like `this`. I thought that might be really useful, especially where I would normally just use uppercase for command names, such as with SERTXD, but I feel it just doesn't look or feel right, is too disruptive in paragraphs with a number of those included.

#### The bear

##### Senior Member
@ Ibenson,
As I see it; In the "Timed switch position" , with the Fet Off, +12v will be present. So pinC.3 = 1 which = No toggle.
I only want the Led flashing when the valve is grounded and therefore on. (Hope I've got that right).
Thanks for your interest and help.
I could be on the verge of a meltdown.

#### lbenson

##### Senior Member
This looks to me like one way of doing. Note that all statements within a block (DO ..., IF ..., etc.) are indented. (Personally, I prefer to indent each block 2 spaces.)
Code:
``````#No_data    ;1 HR delay, ON for 1 Hr, OFF for 2 Hrs, ON  for 1 HR
#Com 3   ;Resets after 24 Hrs

Sertxd("IRRIGATION using Buzby timer v1.0a 12.06.19",13,10)
Symbol minutes = w2
Symbol hours   = w3
Symbol valve  = C.2 'was C.4
Symbol valvesupplyled = C.1
Symbol valvepower = pinC.3
' Start of code
minutes  = 0
hours  = 0
Do
Do ' Hours loop
time = 0  ' Reset in-built seconds counter
Do ' Minutes loop
;----------------------------------------------------
If valvepower = 0 Then '+12v present
if hours = 1 or hours = 4 then
Toggle valvesupplyled 'Flash Led
endif
Endif
;------------------------------------------------
Pause 1000
;Sertxd (#hours,":",#minutes,":",#time,Cr,Lf)  'Com'd out when in use.
Loop Until time > 59 ' *** Should be 59 for one minute
minutes = minutes + 1
Loop Until minutes > 59 ' *** Should be 59 for one hour
hours = hours + 1
minutes = 0
If hours = 1 or hours = 4 Then
Sertxd ("Valve operated ON",Cr,Lf)
High valve  ' Operate Valve ON for 1 Hour
Endif
if hours = 1 or hours = 5 then
Sertxd ("Valve operated OFF",Cr,Lf)
Low valve 'Valve OFF
low valvesupplyled
Endif
If hours = 24  Then  ;was 24
Reset 'Every 24 Hours
Endif
Loop``````

#### The bear

##### Senior Member
@ hippy,
Thank you.
I've been playing in the Sandbox that long, the tide came in and flattened my sand castle.

#### The bear

##### Senior Member
Instead of 'Toggle', I'm going to try 'Pulsout C.1, 5' (mS).

#### BESQUEUT

##### Senior Member
[code=rich]...[/code] if it includes syntax colouring commands.
.
Maybe PE6 should do that for us when we are using "copy for forum..."

#### The bear

##### Senior Member
Hi BESQUEUT,
Good to hear from you.
Just a small update, Pulsout works fine.
Regarding code / code, most people don't seem to have trouble with it.
On the whole, the forum/ PE6 works brilliantly.

#### BESQUEUT

##### Senior Member
Regarding code / code, most people don't seem to have trouble with it.

Code:
``````[color=Green]'Sonnette[/color]
[color=Navy]#no_data

#picaxe [/color][color=Black]20M2[/color]
[color=Green]' Port serie ? 4800 bauds pour 4Mhz[/color]

[color=Blue]do
if [/color][color=Purple]pinc.0[/color][color=DarkCyan]=[/color][color=Navy]0 [/color][color=Blue]then
sertxd([/color][color=Red]"coucou"[/color][color=Black],[/color][color=Navy]13[/color][color=Black],[/color][color=Navy]10[/color][color=Blue])
play b.6[/color][color=Black],[/color][color=Navy]3[/color][color=Black],[/color][color=Navy]%10000000
[/color][color=Blue]endif
loop[/color]``````

#### hippy

##### Technical Support
Staff member
The Post for Forum issue has been noted. In the meantime, changing the [code] tag put at the start of what is pasted to [code=rich] will resolve the display issue.

I suspect posting code hasn't been that problematic due to people using the more familiar Ctrl-C then Ctrl-V sequence to copy and paste, using manually inserted [code]...[/code] tags.

#### BESQUEUT

##### Senior Member
I suspect posting code hasn't been that problematic due to people using the more familiar Ctrl-C then Ctrl-V sequence to copy and paste, using manually inserted [code]...[/code] tags.
And also code size limitation (exploded by color tags...)