Garden Lighting Stepper / Toggle System

Hi Folks,

I'm currently trying to plan out a light control system for my garden that will be controlled by RF initially and later be upgraded to WiFi (probably Zig) when I get some other bits done. My desire is to have the RF signal control a stepper / looper & toggle program on my arduino. Basically the system will respond to either a short or long press and either step through the circuits switching their state or toggle them all on / off. Heres some psuedo code for the logic.

Program
======
cicuitStates is a list of [ 0 => false, 1 => false, 2 => false, 3 => false, 4 => false, n => false ]
stateCheck is false
pressThreshold is 2 seconds
pressLimit is 8 seconds

Main Loop
---------
If a signal is received & it has a value we understand
 
 pressTime is 0

 While a signal is receieved and pressTime is less than pressLimit
  increase pressTime

 If pressTime >= pressThreshold
  Do a long press and pass it the pressTime
 Otherwise
  Do a short press
 
Do a long press
---------------
 Loop through the list of circuitStates and copy all the true indexes to the onArray and the false to the offArray
 set onCount to the length of onArray
 set offCount to the length of offArray
 set waitTime to pressTime - pressThreshold

 If a onCount is >= offCount 
  toggleArray is onArray
 Otherwise
  toggleArray is offArray

 Loop through toggleArray
  Do a switch on the current index
  wait for waitTime // This will create a nice step if desired between the circuits 

Do a short press
----------------
 Loop through the list of circuitStates and look for the first stateCheck (initially false)
 If a circuitStates of stateCheck is found
  Do a switch on that circuit to have the lights either come on or go off
 If no stateCheck is found
  Toggle stateCheck and Do a short press

Do a switch
-----------
 This will receive some value which will direct the switch emitter to the correct circuit using whichever technology.

Maybe additional methods for checkingState, resetSystem, set members etc.

8 Short Presses on 4 circuits would then result in:

| P | 1 | 2 | 3 | 4 |
|-------------------|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 |
| 2 | 1 | 1 | 0 | 0 |
| 3 | 1 | 1 | 1 | 0 |
| 4 | 1 | 1 | 1 | 1 |
| 5 | 0 | 1 | 1 | 1 |
| 6 | 0 | 0 | 1 | 1 |
| 7 | 0 | 0 | 0 | 1 |
| 8 | 0 | 0 | 0 | 0 |

I hope that illustrates what I'm trying to achieve clearly enough.

Here is an image of the circuits I have planned and a few of the problems I face. The topology is a power spine with branch circuits, each circuit being controlled by a switch which responds to a corresponding request from A

The furthest circuit will be 30-40m away and could possibly be obstructed from direct view but I could take measures to make it visible.

A
What is this mechanism? Although my diagram has it pointing to the cable this is of course potentially wireless
If I'm using X10 do I need a dynamic emitter?
If I'm using RF can it be multiple transmitters? I'm probably be stupid here because if my tv remote can handle that many buttons surefly I can do the same? I'm still studying RF
W
This is currently on an independent circuit but I'd very much like to factor it in to the system. The main power feed to these could easily be reached by RF and wireless is pretty much the only option here as I don't want to run cable all over the wall.

Questions:

  1. How should I go about storing the state of each circuit, will writing it in memory be sufficient? Is this persistent through power outs?

  2. What hardware or mechanism should I use to carry out the switching?

2a. For the circuits wired directly to the control box I figure the easiest method will be a bunch of these inline X10 modules (http://www.uk-automation.co.uk/products/Marmitek-X10-Appliance-Module-AM12W.html) I haven't got a clue about wiring these up though, I'm guessing I'd need another X10 device that my arduino can tell what signal to send down the line. This I'm guessing could get quite expensive with the need for 4+ of them but if it is then it is.

2b. As I'm using an rf receiver for the trigger and I should have direct line of site from the control box to the receivers I have been considering using some RF transmitters & receivers, is it possible to transmit multiple different rf signals from a single arduino? Is this a reliable method?

  1. Do any of the above or your suggested options allow the system to poll the circuits to find out what their current state is? I'm thinking for things such as power failure.

  2. Am I ignoring another comm protocol that would be useful here, WiFi?

  3. Is this even doable with a single arduino?

I'm sure I have a lot more questions but I'll add them when they occur.

Any one have any thoughts? Need any more info? Thanks in advance :slight_smile:

Edit: Updated while loop logic to allow for variable wait during doLongPress

Anyone? Is this even plausible or should I get back to the board?