Can anyone kindly get me started?

Hi all

In brief im trying to achieve as follows- RELAY ONE (ON 10 SECONDS OF 10 SECONDS) RELAY TWO (ON 10 SECONDS OF 10 SECONDS) RELAY TWO TO START AS RELAY ONE STOPS AND AS RELAY TWO STOPS RELAY ONE TO START (LOOP)

Im not expecting anyone to write a whole programme for me but im eager to start learning and have idea where to start.

Any info would be great!

Thanks
Mike

Start here: How to use this forum

Pete

Enough with the shouting before I put your posts in the bin.

Use upper and lower-case for your question and your thread title.

  • Moderator

Hi
Im very sorry , its a bad habit of mine when im trying to say something complicated quickly and clearly so it is easy to read and it allows me to miss out can miss out punctuation.

im most certainly not shouting but i am getting really frustrated as i can find no parameters or starting/reference points to start learning code

sorry for any offence caused im really just trying to learn something new and it really isnt easy but i will keep trying even if it kills me

all the best
Mike

Hi all

In brief im trying to achieve as follows- RELAY ONE (ON 10 SECONDS OF 10 SECONDS) RELAY TWO (ON 10 SECONDS OF 10 SECONDS) RELAY TWO TO START AS RELAY ONE STOPS AND RELAY TWO STOPS AS RELAY ONE STARTs (LOOP) (Caps lock for clarity)

I imagine it will be something like two blink sketches with something complicated in the middle. :O)

Im not expecting anyone to write a whole programme for me but im eager to start learning and have idea where to start.

Any info would be great!

Thanks
Mike

You seem to be aware of BlinkWithoutDelay so, using that principle

define output pins and modes
define the switching interval
turn on relay1
set flag to indicate that relay1 is on
set start time to millis

start of loop
  if it is time to swap relays //millis() - start time > interval
    if relay1 is off
      output HIGH to relayPin1
      output LOW ro relayPin2
      set flag to indicate relay1 is on
      end of if
    else
      output LOW to relayPin1
      output HIGH ro relayPin2
      set flag to indicate relay1 is off
    end of else
    set start time to millis
  end of if
end of loop

Excellent! Thank you so much!

Its still massively complicated but im going to focus and concentrate on what you have written for me untill i get it (its gonna be a long day)

Thank you so m uch for taking the time to write and help

Mike

(ON 10 SECONDS OF 10 SECONDS)

Is that meant to be "on ten seconds, off ten seconds" ?

hi

relay one switch on for 10 seconds then stop/off/ for 10 seconds, as relay one switches off relay two to start the same sequence (loop)

many thanks

Mike

MIG18WOW:
Im very sorry , its a bad habit of mine when im trying to say something complicated quickly and clearly so it is easy to read and it allows me to miss out can miss out punctuation.

Start one more thread about this and I will delete all of them and your account.

No good saying "sorry" if you keep doing it. I'll be sorry too.

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

  • Moderator

What your asking for is just a slight derivative of the "blink" example provided in the IDE.

I've gone ahead and written something for you that should work. Note, that I don't have my Arduino next to me to test this. So hopefully I left a few little bugs for you to work out.


//global variables
int relay1_pin = 4;
int relay2_pin = 5;
int duration = 10000;		//in milliseconds

void setup() {
	pinMode(relay1_pin, OUTPUT);
	pinMode(relay2_pin, OUTPUT);
}

void loop() {
	blink(relay1_pin);
	blink(relay2_pin);
}

void blink(int pin) {
	digitalWrite(pin, HIGH);
	delay(duration);
	digitalWrite(pin, LOW);
}

Now, you mention using this to drive relays...you might want to list the specs on your relays. The Arduino can't operate relays outside its voltage/power range.