Hi everybody! This is my first post on the forum so forgive me if I'm not abiding by any of the forum rules.
My question:
I'm trying to take in input from a Wii nunchuck and use it in my project. I have looked up the code that I should use for this purpose and all of tutorials show the data and clock cables connected into pins A5 and A6, I believe. But I already have those pins occupied by an IMU sensor's data and clock cables.
Is there a way around this? Maybe, make a few modifications in the code and get the nunchuck's wires go to any other analog pins?
All help is greatly appreciated.
Thank you.
The two devices can share the I2C bus (A4 and A5) because they have separate addresses. The wiiChuck is address 0x52.
I think the wii controller is I2C (you wrote A5/A6 in the post, A4/A5 in the title). If so, you can talk to both devices just by changing the address when calling Wire.beginTransmission().
I don't know at which frequencies you need to do the readings.
thank for the quick replies, guys. Yes, sorry for the confusion. i meant, A4 and A5. I have Arduino Uno, so no A6 on the board. lol.
I am planning to use the following code to get the values from my nunchuck.
http://www.windmeadow.com/index.php?q=node/42
You mentioned something changing the address while calling the function, wire.transmission(). I should make it clear that I don't really know a great deal about coding. I'm just an undergrad mechanical engineer trying to harness the seemingly amazing power of Arduino! I have been self teaching myself but haven't gotten so far as to know what the 'addresses' are. If you can break it down in simple layman terms, I would really appreciate that. I realize, it could be a little annoying to respond to all these naive questions but we all are greatly appreciative of you people coming out here and taking time to respond to our queries.
Quick explanation with a lot of omissions:
I2C (sometimes called 2-wire) is a bus where there is a master (the arduino) and a series of slave devices attached to it (sensors, your nunchuck for example), in parallel.
Usually every slave device has an ID (the address). When the master wants to talk to a slave device, it transmits the slave address as the first byte. The slaves, that are listening on the bus, receive this byte. If it matches their address, they keep listening for data. Otherwise they'll ignore other data. You can see the address is needed with I2C communication, because the I2C is a shared bus.
By changing the address passed in the Wire.beginTransmission() function, you are specifying the slave device you want to talk to. The same goes for Wire.requestFrom(), but in this case you pass the address of the device you want to receive from.
The slave address is specified in the datasheet of the component you're using (0x52 for the nunchuck, I don't know which IMU you are using).
I recommend you to read more on I2C since a lot of sensors out there use this bus.
I think, I have a good rudimentary idea of how this works. I will definitely read up a little more on the subject. Thanks for keeping it terse.
Good day!