pic i2c硬件通信程序 c语言,求红外测距传感器GP2Y0E03通过i2c与pic单片机通信

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

如下是例程,但是,按照程序的指示,似乎是直接连接单片机的A4A5接口,然而,电压范围不同,会不会有问题,建议在拿不准的情况下,加上电压转换装置。

***************************************************************

Arduino GP2Y0E03 example code

Gets range from GP2Y0E03 and prints it to the serial monitor.

Pin Connect:

GP2Y0E03 Arduino

1.PIN--VCC 3V3

2.PIN--Vout(A) Not Connect

3.PIN--GND GND

4.PIN--VIN(IO) 3V3

5.PIN--GPIO1 3V3

6.PIN--SCL A5

7.PIN--SDA A4

***************************************************************/

#include

int distance = 0; // Stores the calculated distance

byte high, low = 0; // High and low byte of distance

int shift = 0; // Value in shift bit register

#define ADDRESS 0x80 >> 1 // Arduino uses 7 bit addressing so we shift address right one bi

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值