Halloween Forum banner

1 - 9 of 9 Posts

·
Registered
Joined
·
190 Posts
Discussion Starter #1
Is there a way to have an Uno run in a loop by jumping 2 connections, not by code, much the same way you can with a Picoboo? I'm wanting to run it with relays connected without a PIR and have the sequence run over and over? So basically when power is applied to the UNO it's starts playing the programmed sequence and doesn't stop until power is removed. In my case I want to have it turn on one light then turn on another light and repeat this indefinitely.
 

·
Registered
Joined
·
337 Posts
It is not clear what you are asking If you write your Arduino code to run in an endless loop then when you power it up it will run that sequence over and over until power is removed.
 

·
Registered
Joined
·
190 Posts
Discussion Starter #4
I'm not writing code, just using the four banger software to program the Uno. That's why I was asking if there was a way to jump 2 contacts on the Uno as on the Picoboo if you run a jumper wire from the ground to the in on the trigger input it loops the playback and runs continuously.
 

·
Registered
Joined
·
74 Posts
Like JW Halloween said, the Arduino will start automatically and loop as long as the power is on. Here is the code to toggle two relays on and off. Everything is commented (the "// whatever") so you know what each line will do. As it is written, relay 1 turns on, there is 2 second delay, relay two turns on, there is a 10 second delay, relay 1 turns off, there is a 2 second delay, relay 2 turns off, there is a 10 second delay and it starts over. You can change the delay or the order the relays turn on/off easily.

Enjoy!

/*
This sketch is a simple loop with two relays. There is a variable delay after each relay triggers to keep it energized.
*/
// declare global varibales
int relay1 = 6; // Pin of Relay1 Module
int relay2 = 7; // Pin of Relay2 Module

// setup loop
void setup()
{
pinMode(relay1, OUTPUT); // Set Pin connected to Relay as an OUTPUT
digitalWrite(relay1, HIGH); // Set Pin to HIGH to turn Relay OFF
pinMode(relay2, OUTPUT); // Set Pin connected to Relay as an OUTPUT
digitalWrite(relay2, HIGH); // Set Pin to HIGH to turn Relay OFF
}
// main program loop
void loop()
{
digitalWrite(relay1, LOW); // Turn relay1 ON
delay(2000); // 1000 = 1 second
digitalWrite(relay2, LOW); // Turn relay2 ON
delay(10000); // length of time both relays are on, 1000 = 1 second
digitalWrite(relay1, HIGH); // Turn relay1 OFF
delay(2000); // 1000 = 1 second
digitalWrite(relay2, HIGH); // Turn relay2 OFF
delay(10000); //length of time relays are off, 1000 = 1 second
}
 

·
Registered
Joined
·
190 Posts
Discussion Starter #6
Never worked with coding of Arduino? I've only used the Four Banger software which is pretty idiot proof!
How would I input this? I keep getting errors when I try. Here's what I see in Arduino IDE


void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
 

·
Registered
Joined
·
74 Posts
In the IDE delete everything that is there then paste my entire block of code. Upload to your Arduino.

If this is your first time using the IDE you may need to select the proper board. Click Tools > Board and select the board you have. The "Arduino/Genuino Uno" works for most generic boards. You may also need to select the proper port. Plug the Arduino board into your PC via the USB cable then click Tools > Port. You should see the USB connection listed as COMx. If you have more than one you can try each one till you find the proper one for your setup. On the bottom of the IDE there will be text that says something like "COM4 - Genuine UNO" when you get the port right.

I assume you already have the relays and know how to wire them. If not let us know and someone can jump in.
 

·
Registered
Joined
·
26 Posts
with an uno you should be able to jump the normally open portion of the wiring, just make sure you set the delay to the amount of time you want between sequences.

Uno wiring.jpg
 

·
Registered
Joined
·
190 Posts
Discussion Starter #9
Techster for the win! That did it. I figured there'd be a jump 2 pins solution! I appreciate the help all!
 
1 - 9 of 9 Posts
Top