90Views11Replies

Author Options:

Can you use one nano running a sequence to trigger 8 other nanos to run each of their sequences? Answered

I have 8 nanos running different sequences and I want to use another nano running a sequence to trip each one of those.

Tags:LED

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
spiffomatic64
spiffomatic64

Best Answer 8 years ago

I dont have a nano, but I dont see why not... dedicate one pin on each of the nano's as an input, then on the "master" dedicate 8 pins as outs to trigger the other nano's...

If you wanted to get complicated, you could piggy back the serial connections (assuming the nano's work the same as the uno/standard arduinos) and have code to look for commands for each nano.

for example, nano1 starts its sequence, and sends a serial message of "2" this gets sent to all of the nano's but only 2 is coded to react to a "2" sent over serial then start its sequence.

If you explain the exact setup/goal we may be able to answer this better...

Also let me know if my explanation doesnt make sense :)

0
slowguy
slowguy

Answer 8 years ago

Your answer makes sense. Just do not know how to do it. What I am doing is making a light show. 8 nanos are each running different LED sequences for a predetermined time then stop and I want to trip each one in order. I want to keep it simple.

0
steveastrouk
steveastrouk

Answer 8 years ago

If you have 8 spare outs on your primary nano, then you use one out to each other nano. The other nanos watch their input pins for the primary nano to go high, when it does, their sequence is triggered.

OR/

Primary nano - output - 1st nano input - 1st nano output- 2nd nano input - 2nd nano out ...

...and chain them together primary nano says go, 1st nano sees line goes high, does its stuff, sends ITS go line high to the NEXT nano.

Steve

0
spiffomatic64
spiffomatic64

Answer 8 years ago

I didnt test this code but in my head this should work

Master nano:
#define nano1 3
#define nano2 4
#define nano3 5
#define nano4 6
#define nano5 7
#define nano6 8
#define nano7 9
#define nano8 10


void setup() {
// initialize the digital pin as an output.
pinMode(nano1, OUTPUT);
pinMode(nano2, OUTPUT);
pinMode(nano3, OUTPUT);
pinMode(nano4, OUTPUT);
pinMode(nano5, OUTPUT);
pinMode(nano6, OUTPUT);
pinMode(nano7, OUTPUT);
pinMode(nano8, OUTPUT);
}

void onoff(int pin)
{
digitalWrite(pin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(10); // wait for a 1/100 of a second
digitalWrite(pin, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}

// the loop routine runs over and over again forever:
void loop() {
onoff(nano1);
onoff(nano2);
onoff(nano3);
onoff(nano4);
onoff(nano5);
onoff(nano6);
onoff(nano7);
onoff(nano8);
}

Example for one of the "slaves"

#define in 3

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the pushbutton pin as an input:
pinMode(in, INPUT);
}

void loop(){
int inputstate = digitalRead(in);

if (buttonState == HIGH) {
//do your sequence here
}
}

Play with this for a bit.
Place wires from pins 3-11 on the master to pin 3 on all of the slaves

0
slowguy
slowguy

Answer 8 years ago

master is working great but having trouble with my slave. He is my sketch. can not get it to trigger.
#define in 3

// variables will change:
boolean t = true;
int i = 12;
int buttonState = 0; // variable for reading the pushbutton status

void setup() {

pinMode(in, INPUT); // initialize the pushbutton pin as an input:
pinMode(12,OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
pinMode(5,OUTPUT);
pinMode(4,OUTPUT);
}

void loop()
{
int inputstate = digitalRead(in);

if (buttonState == HIGH)
{
//do your sequence here
digitalWrite(i,HIGH);
delay(50);
digitalWrite(i,LOW);
if(t == true)
{
i = i - 1;
}
else
{
i = i + 1;
}
if(i < 5)
{
i = 6;
t = false;
}
if(i > 12)
{
i = 11;
t = true;
}
}
}

0
spiffomatic64
spiffomatic64

Answer 8 years ago

lol oops typo on my part :)

change
if (buttonState == HIGH) {

to if (inputstate == HIGH) {

0
slowguy
slowguy

Answer 8 years ago

thanks you so much, it works great

0
slowguy
slowguy

Answer 8 years ago

ok, will do. thanks

0
spiffomatic64
spiffomatic64

Answer 8 years ago

or if you want to look into the i2c (I've never done this myself, but have heard of it) http://www.uchobby.com/index.php/2008/09/16/introduction-to-i2c/

0
steveastrouk
steveastrouk

Answer 8 years ago

There are also ways of extending the IO on an Arduino, so you only need one nano.

0
rickharris
rickharris

Answer 8 years ago

+1

I don't know the nano but it may well support IC2 bus or a serial link which makes the communications easier and twin wire.