View unanswered posts | View active topics It is currently Mon Dec 22, 2014 7:50 pm






Reply to topic  [ 7 posts ] 
Help with I2C 
Author Message
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Help with I2C
I'm trying to figure out some of the I2C stuff. So, say I want to send 0x04 to the register 0xfe on the address 0x53 on a sensor that's plugged into port 1. How would that be accomplished? Well, at least I think that's what I want to figure out. Is that what this code does?
Code:
Wire.beginTransmission(0x53);
Wire.send(0xfe);
Wire.send(0x04);
Wire.endTransmission();
If not, then what does it do?

Also, how to receive? If I send 0x00 to address 0x52, and it sends back 6 bytes, how do I read that?

Thanks,

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue Oct 02, 2012 1:06 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: Help with I2C
This looks like Arduino to me, not ROBOTC. If you want a tutorial on I2C, you can find one on my site: http://botbench.com/blog/2009/11/08/rob ... to-part-i/

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Oct 02, 2012 1:55 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Help with I2C
Yes, the code I pasted in is Arduino. I want to translate that code to RobotC. I didn't know about your article, will check it out.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue Oct 02, 2012 1:58 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: Help with I2C
I have quite a few tutorials on my site :) Click on the "tutorials" button to bring up all the articles under that specific heading.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Oct 02, 2012 2:00 pm
Profile WWW
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Help with I2C
Yes, in Arduino C/C++, that would indeed send 0x04 to register 0xFE of slave 0x53.

It looks like you are trying to read a Wii extension using an Arduino, in which case I think you mean address 0x52, not 0x53. There are a number of libraries already available for reading e.g. a nunchuk.

Alternately, I would suggest you convert the library that I recently emailed to you.

BTW, the Wire library often used with Arduino C/C++ expects I2C addresses to be 7 bit (bits 0-6) instead of the more common 8 bits (bits 1-7, with bit 0 false).

_________________
Matt


Tue Oct 02, 2012 4:15 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Help with I2C
No, not with an Arduino. I'm trying to read the Wii Motion+, and found some Arduino code for it that I wanted to make sure I was understanding correctly. The copy of the library you sent me does not seem to contain any code for the WM+.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue Oct 02, 2012 4:28 pm
Profile WWW
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Help with I2C
I attached it to the email I sent you on 10/01/12 at 15:31.

_________________
Matt


Tue Oct 02, 2012 4:32 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.