Arduino chain...possible?


I wish to set up an arduino chain !! For example

5 arduinos
1 cable connected on pin 0&1 (rx/tx) of EACH arduino (going from 1 to 2, 2 to 3, and so on…)
1 push button for each arduino (input pin 5 for example)
each arduno as a different code inside

arduino 5 is connected with USB to the computer

when pressing button on arduino 1, one serial message is sent with content “1”
when pressing button on arduino 2, one serial message is sent with content “2”
and so on…

lI wish the message goes all over the ardiono chain till the computer. goal : use one single cable.

but i don’t see how to allow an easy transit from one board to the enxt one till the computer

my code :

int inPin = 5; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status

void setup() {
pinMode(inPin, INPUT); // declare pushbutton as input


void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)

thanks to all for ideas !!


des idées ?



I doubt this is the best solution, but just off the top of my head, use the software serial library to create a second serial port. Then each arduino will basically.

poll the button, if pressed output a message on the hardware serial port.

poll the software serial port, if a byte is present, output on the hardware serial port

The major flaw I can see is when you have several multi-byte messages happening at the same time, but a protocol can be worked out to deal with that.