Good morning! This is my first post here, and my first time diving into the world of microcontrollers. Bear with me, as I describe this theoretical project.

I've got an Arduino Mega 2560, two Arduino Unos, one accelerometer, two Wii Nunchucks (with Nunchucky adapters) and two 3-axis joysticks. I'm curious how to go about wiring/programming the two Unos to the Mega as slaves; both with one nunchuck and joystick going to them to control a set of servos/actuators each, for a total two sets of servos/actuators. The accelerometer will be connected directly to the Mega, and will control a third set of servos/actuators via head-tracking (accelerometer mounted to a headset).

I've been reading all over, and the first thing I need to learn is how to go about establishing I2C between the Mega and two Unos. I found a few diagrams, but wasn't sure if that way was best for my application. After the I2C is established, I am interested in learning how to make accelerometers and joystick potentiometers most effectively control servos and actuators. I'm also interested in how to program buttons to playback pre-programmed servo sequences, but I'm getting way ahead of myself. If anyone's wondering about this project, it's for a large animatronic suit. Any advice is welcome, and thanks for reading!

*edit: I made a sketch in Fritzing to give you an idea of what I have in mind. Don't mind the accelerometer on the left- that'll come later when I get into solenoids. enter image description here

  • 2
    Welcome to StackExchange! This is a very broad question, or indeed, series of questions. You can read my thread about I2C - but for the rest I suggest you break it into a series of more specific questions. Your project sounds feasible. Have fun! – Nick Gammon Sep 6 '15 at 20:39
  • Just my opinion, but usually I tend to create networks of microcontrollers only when strictly necessary. This includes cases where two or more parts have to communicate wirelessly, or when one uC is too small (usually flash, but sometimes even pins, even if it is easier to use port expanders). If you want to make them communicate for learning how different buses work, ok, but if you have a project in mind better pack everything inside a single arduino; if it lacks resources, expand, but usually this is not the case ;) – frarugi87 Sep 27 '17 at 7:29

Welcome to the wonderful world of microcontrollers! Looks like an exciting project, and you will definitely learn a lot!

As for wiring with I2C, you have a few things to connect:

  • SDA (the "data" line)
  • SCK (the "clock" line)
  • GND (ground)

For I2C (which is also called TWI for two-wire interface), you connect all like lines together. This means connect all the SDA pins (analog pin 4 [A4] on Unos, digital pin 20 on the Mega) and all the SCK pins (analog pin 5 [A5] on the Unos, digital pin 21 on the Megas). I think the schematic is different than this. I can't read the actual lettering on the boards because the image resolution is not high enough. You also want to connect all the ground pins together, which you've done in your drawing.

If you want a quick way to get up and running with I2C, use the example sketches in the Arduino programming environment. Open up Arduino, then go to File > Examples > Wire. In your case, I would pick one master and use the other two as slaves. I would try using the master_writer on the Mega and slave_receiver on the 2 Unos. A good idea would be to leave all of the accelerometers, potentiometers, etc. off to start. Just have the master send a command to the two slaves, and when they receive it they can light up their on-board LED:

digitalWrite(13, HIGH)

Another note: the Fritzing sketch shows a 3.7V battery powering the Arduinos, but they need 6-20V and it's best to use 7-12V. This may just be a filler battery you threw in for the drawing, I understand. Just in case, I thought I'd mention it.

As suggested by Nick Gammon above, you will probably get the best response by breaking up the rest of your post into individual questions. Good luck with your project! Sounds like a fun one!


Firstly, you need to study a bit of the I2C protocol.

In it, there is an expanation about something called Address, and something more about specifying the master or the slave nodes.

So, you need test some points prior to mount all the system.

  • Test the master I2C communication.
  • Test the first I2C slave with its address.
  • Test the second I2C slave with its address.
  • Test the interconection between the 3 elements (remember to put pullup resistors in SDA and SCL!)

Hope it helps


Arduino or AVR chips not use I2C protocol, but technically alternative TWI = it's not full I2C protocol. Please not use external pullup resistors with SDA and SCL on Arduino, if you not disable internal pullups. Arduino IDE has I2C/TWI library activated with internal pullups on begin transmitting and internal pullups are 10-50K. AVR chips have pullups integrated. The TWI does not set it as 100% open-drain. Because there are protection clamping diodes to VCC and GND. If an Arduino is Slave, and it has the power turned off, that will keep the SDA and SCL low via the diodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.