Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

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

share|improve this question
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 at 20:39

1 Answer 1

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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