Animatronics project: wired arduino communication

Hi guys,

I am thinking about starting a really cool animatronic and my question is this:

I want to use one arduino to take readings from sensors and then use those values to determine what position servos should be in to mimic the movement. So I think the best way is to read the values using one arduino to read the sensor and send the servo position to the other arduino

The final lines being the determined servo positions.

Serial.print(servo1)
Serial.print(servo2)
Etc....

Then receive on the other Arduino and write to the servo

Servoangle1 = Serial.read() // this is reading the line sent from the other Arduino (Serial.print(servo1)
Servoangle2 = Serial.read()
Etc... Then:

servo1.write(Servoangle1)
servo2.write(Servoangle2)
Etc..

So to the question! First: does is code look vaguely along the right lines style wise. (Mainly, will the reciver read the serial.print statements in order so that the angles like Servoangle1 will be read in the right order?

Secondly: can the communication be done using this. https://www.arduino.cc/en/Tutorial/MasterWriter it seems like it would do the job.

Thanks very much, sorry if the questions are a bit confusing I'm struggling to convey things properly. I'd be happy to clarify anything :slight_smile:

George

How many sensors & servos? Maybe just a uC with a little more IO and keep it all in one part.
'1284P has 32 IO and will do at least 12 servos.

Use the KISS principle vs complicating things.
I offer 1284P boards in several form factors here from something Uno like to other smaller sizes and a board with more parts
http://www.crossroadsfencing.com/BobuinoRev17/

My plan is to use 5 input sensors to control 5 servos

It would be very strange if you can't easily do 5 inputs and 5 servos on an Uno. Keep in mind that the analog pins can also be used as digital pins.

If you really do want to use two Arduinos be sure to use ones that have extra hardware serial ports such as the Mega or a board using an Atmega32U4. And you may be interested in Serial Input Basics

...R