大本赢彩票开户

码迷,xscp18.com
大本赢彩票开户 > 其他好文 > 详细

Arduino 寻找I2C地址address

时间:2019-11-01 00:12:05      阅读:23      评论:0      收藏:0      [点我收藏+]

标签:date   dep   ref   find   byte   margin   oop   cap   mes   

参考:http://henrysbench.capnfatz.com/henrys-bench/arduino-projects-tips-and-more/arduino-quick-tip-find-your-i2c-address/

Arduino Quick Tip:  Find Your I2C Address

Contents []

Don’t Get Hung Up When You Want to Play

You’ve just received your new module and you want to test it.  You go back the seller’s web page and find instructions that are only slightly clearer than mud.  In fact, one of things you discover as you attempt to unravel the odd form of English that is used is that you can’t seem to figure out what the I2C address is.

You can certainly find the data sheet for the device that the module is built around。 With a little work, you should also be able to  identify the address pins。  Then, with a little probing,  you can identify the address。

In fact, at some point in your project development, it may even become necessary.   Alas,  sometimes you only have a few minutes to play and you just want to see the freaking thing work.

If that describes you, then try running the following sketch.  It will scan I2C possible addresses and report the address of the device that responds.

address of the device that responds.



I2C Scanner By Nick Gammon

Copy, Paste, Upload and Run!

 

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

I2C Scanner Results

Run the sketch and you will see a result that looks something like this:

 

 

 

 

大本赢彩票开户Arduino 寻找I2C地址address

标签:date   dep   ref   find   byte   margin   oop   cap   mes   

原文地址:https://www.cnblogs.com/MCSFX/p/11774266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
           
© 2014 xscp18.com 版权所有 京ICP备13008772号-2
迷上了代码!
艾米彩票开户 人人发彩票开户 龙头彩票开户 天天彩票开户 万彩会彩票开户 亿信彩票开户 赢天下彩票开户 百胜彩票开户 印象彩票开户 菜鸟彩票开户