blink in synchro

hi!

I am using a modified version of the sketch "blink", in which one board blinks and toggles a digital pin on/off so a second board blinks in synchro.

I copy both sketches (master and slave) below.

the question is, if I want to use more than one slave, can I use the same digital pin in the master and simply split the cable, or do I need a second digital pin for the second slave?

master

// Master
const byte ledPin = 13;
const byte syncoutPin = 8;

void setup()
{
  pinMode(syncoutPin, OUTPUT);
  digitalWrite(ledPin, HIGH);

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
}

void loop()
{
  // toggle sync pin
  digitalWrite(syncoutPin, !digitalRead(syncoutPin));
  // toggle led on master
  digitalWrite(ledPin, !digitalRead(ledPin));
  delay(1000);
}

slave

// Slave
const byte ledPin = 13;
const byte syncinPin = 9;


void setup()
{
  Serial.begin(115200);
  
  pinMode(syncinPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
}

void loop()
{
  static byte lastSyncState = HIGH;

  // blocking (!!) wait for sync state change
  while (digitalRead(syncinPin) != lastSyncState);

  // some debug
  Serial.println("syncin state changed: ");

  // toggle led on slave
  digitalWrite(ledPin, !digitalRead(ledPin));
  // update last sync state
  lastSyncState = !lastSyncState;
}

so your plink is working between the two correct? and the third board do you want it connect to the master or would you prefer to connect it to the slave and let the slave trigger to the second slave a blink after it receives its blink. just making sure I got it right.

There is an 'electrical' limit to the number of parallel inputs you can feed from a single output, this loading is affected by the number, length and other values.

Paralleling two or three inputs from a single driven output pin shouldn't be an issue with fairly short wires. You can use buffers to increase the number, but then other factors will come into play.

thank you very much lastchancename

I am going to perform a practical test and come back with the results.

plan B, is to program the slave so they as well toggle a pin for the next slave. or perhaps it should be even my main plan...

happy sunday!

camilozk:
plan B, is to program the slave so they as well toggle a pin for the next slave. or perhaps it should be even my main plan...

Another option is to produce the synchronizing pulse on a few pins on the master and connect each pin to a few of the slaves. If your use Port Manipulation on a single Port the pins will change at the exacat same time. However even using digitalWrite() to a few different pins the slight difference in timing would probably not be noticeable.

...R

thanks robin!

I did program already the slave(s) to toggle as well a pin to the next board, and works very nice

:slight_smile: