简体   繁体   English

我应该在arduino uno上为i2c采取哪些引脚

[英]which pins should i take for i2c on arduino uno

I am trying to create an i2c communication bus with an arduino UNO. 我正在尝试用arduino UNO创建一个i2c通信总线。

i2c requires SDA and SDL pins. i2c需要SDA和SDL引脚。 I see on arduino UNO there is twice SDA and SDL: 我在arduino UNO上看到有两次SDA和SDL:

The 2 first pins side to usb connector are SDA/SCL according to documentation. 根据文档,USB连接器的2个第一引脚侧是SDA / SCL。

And the documentation says A4 and A5 pins can also be SDA/SCL 文档说A4和A5引脚也可以是SDA / SCL

So i do not understand which pins i can use. 所以我不明白我可以使用哪些引脚。

在此输入图像描述

Thanks 谢谢

Look at the complete diagram: 看一下完整的图表: 在此输入图像描述 http://pighixxx.com/unov3pdf.pdf http://pighixxx.com/unov3pdf.pdf

SDA and SCL pins are PC4 and PC5 pins of the microcontroller (pin number 4 and 5 of port C). SDA和SCL引脚是微控制器的PC4和PC5引脚(端口C的引脚号4和5)。 Pins A4 and A5 are also PC4 and PC5. A4和A5针也是PC4和PC5。 This means they are connected together. 这意味着它们连接在一起。

So you can use any of these, it does not matter. 所以你可以使用其中的任何一个,这没关系。

The earlier versions of the Uno did not have the separate SDA/SCL pins. 早期版本的Uno没有单独的SDA / SCL引脚。 Then as they started making other boards (such as the Leonardo) there was a problem that the Leonardo SDA/SCL pins were not A4/A5 (they are D2/D3). 然后当他们开始制作其他电路板(例如Leonardo)时,有一个问题是Leonardo SDA / SCL引脚不是A4 / A5(它们是D2 / D3)。

To make it easier to make shields which use I2C the manufacturer added the SDA/SCL pins in a known location. 为了更容易制作使用I2C的屏蔽,制造商在已知位置添加了SDA / SCL引脚。 For both boards they are connected to the correct pins for that board. 对于两块板,它们都连接到该板的正确引脚。

A similar remark applies to the later versions of the Mega2560 board. 类似的说法适用于Mega2560板的更高版本。

You can use either pins: the ones marked SDA/SCL or the appropriate pins for the board to hand. 您可以使用任何一个引脚:标记为SDA / SCL的引脚或用于电路板的相应引脚。 They are connected together so it doesn't matter which ones you choose. 它们是连在一起的,所以选择哪一个并不重要。


Partial schematic from the Uno showing the two sets of pins are on the same "net" which means the pins are internally connected. 来自Uno的部分原理图显示了两组引脚位于同一“网”上,这意味着引脚在内部连接。

Uno上的SDA和SCL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM