参考: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

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.

.HenryBenchResponsive { width: 320px; height: 100px }
@media (min-width: 800px) { .HenryBenchResponsive { width: 468px; height: 60px } }
@media (min-width: 1125px) { .HenryBenchResponsive { width: 728px; height: 90px } }

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的更多相关文章

  1. Arduino通过I2C(PCF8574T)驱动1602LCD

    Arduino中使用I2C通信可直接调用Wire.h库, 这个库允许Arduino链接其他I2C设备, 链接线有两条, 分别是SDA(数据行)和SCI(时钟线). 各型号Arduino的I2C对应引脚 ...

  2. Arduino通过I2C(SSD1306)驱动0.96寸12864OLED

    I2C驱动的128x64 OLED I2C (Inter-Integrated Circuit) 集成电路总线是I2CBus的简称, 是一种串行通信总线, 使用多主从架构. 飞利浦公司在1980年代为 ...

  3. Davinci-DM6467板子-外围器件的I2C地址的疑惑解答

    这篇文即调试标清视频或者说调试TVP5147和ADV7343所使用的程序名称为video_sd_playback_480i_composite 我们用的是合众达公司(SEED)的SEED-DVSD64 ...

  4. 地址(Address)——WCF学习笔记(2)

    地址(Address)分为: 统一资源表示(URI). EndpointAddress. 端口共享. 逻辑地址与物理地址. 请求监听与消息分发.

  5. The three day 给你一个有效的 IPv4 地址 address,返回这个 IP 地址的无效化版本

    """ 给你一个有效的 IPv4 地址 address,返回这个 IP 地址的无效化版本. 所谓无效化 IP 地址,其实就是用 "[.]" 代替了每个 ...

  6. 通过PEB寻找函数地址

      通过PEB的Ldr参数(结构体定义为_PEB_LDR_DATA),遍历当前进程加载的模块信息链表,找到目标模块.   摘自PEB LDR DATA: typedef struct _PEB_LDR ...

  7. 第2章地址Address(WCF全面解析3)

    WCF顾明思义,就是在Windows平台下解决通信(C,Communication)的基础框架(F,Foundation)问题. 终结点是WCF最为核心的对象,因为它承载了所有通信功能.服务通过相应的 ...

  8. 23.实现一个名为Person的类和它的子类Employee,Employee有两个子类Faculty 和Staff。 具体要求如下: (1)Person类中的属性有:姓名name(String类型),地址address(String类型), 电话号码telphone(String类型)和电子邮件地址email(String类型); (2)Employee类中的属性有:办公室office(Stri

    package banking; public class Person { private String name; public String address; public String tel ...

  9. 地址(Address)——统一资源表示(URI)——WCF学习笔记(2)

    统一资源标识(URI) URI:Uniform Resource Identifier(统一资源标识),唯一地标识一个网络资源的同时也表示资源所处的位置的方式(资源访问所用的网络协议). URI结构: ...

随机推荐

  1. 只有一重循环的排序——侏儒排序(Gnome Sort)

    侏儒排序:从头(i=0)开始遍历元素,如果当前元素比前一个元素大(array[i]>array[i-1]),就把它跟前一个元素互换(Swap(a[i],a[i-1]))并继续检查它(i--),否 ...

  2. 你不得不知的Java基础知识

    本篇博客主要记录Java中面向对象的概念和Java语法的基础知识. 面向对象 什么是面向对象 面向对象是一种优秀的软件设计思想,是相对于面向过程.面向切面等设计思想的一种软件设计理念.它的核心思想是运 ...

  3. 【CF】Sereja and Arcs

    #include <bits/stdc++.h> #define llong long long using namespace std; const int N = 1e5; const ...

  4. luogu P3796 【模板】AC自动机(加强版)

    知识点:1.一定要删掉调试信息 2.数组别重名 code: #include <bits/stdc++.h> using namespace std; int n; int len[]; ...

  5. ASP.NET Core 性能优化最佳实践

    本文提供了 ASP.NET Core 的性能最佳实践指南. 译文原文地址:https://docs.microsoft.com/en-us/aspnet/core/performance/perfor ...

  6. [程序员代码面试指南]递归和动态规划-机器人达到指定位置方法数(一维DP待做)(DP)

    题目描述 一行N个位置1到N,机器人初始位置M,机器人可以往左/右走(只能在位置范围内),规定机器人必须走K步,最终到位置P.输入这四个参数,输出机器人可以走的方法数. 解题思路 DP 方法一:时间复 ...

  7. Linux实战(7):centos7安装xrdp

    系统环境:最小化安装,无安装桌面化 操作 yum更新 yum -y update 安装依赖. tigervnc-server.xrdp .GNOME Desktop yum -y install ep ...

  8. 218。重复元素II(重复元素的下标差值<=K)(哈希)

    给定一个整数数组和一个整数 k,判断数组中是否存在两个不同的索引 i 和 j,使得 nums [i] = nums [j],并且 i 和 j 的差的 绝对值 至多为 k. 示例 1: 输入: nums ...

  9. 格式化时间戳的n种方法

    1 var time = new Date(ele.time).toLocaleString().split(' ')[0] 2 formatDate: function (value) { let ...

  10. 项目初始化CSS公共样式

    /*! normalize.css v6.0.0 | MIT License | github.com/necolas/normalize.css */ /* Document =========== ...