20、嵌入式设备与 1-Wire 总线通信:TINI 应用指南

嵌入式设备与 1-Wire 总线通信:TINI 应用指南

1. 1-Wire 设备通信示例

首先,来看一个读取温度传感器的示例代码:

// Read the temp sensor
myTherm.measureT();
// Display what we know (temoerature) in C and F
System.out.println(“The device ROM ID: “ + myTherm.ROM_ID);
System.out.println(“The measured temperature: “ + myTherm.degC
+ “ Deg C”+ “, or “ + myTherm.degF + “ Deg F”);

这个示例程序虽然没有利用 DS1920 温度 iButton 的所有功能,但展示了如何使用 OneWireContainer10 类与设备进行通信。以下是不同环境下的运行示例:
- Windows 系统
- C:\> java Thermometer
- 输出:

The device ROM ID: D40000004B996410
The measured temperature: 24.0 Deg C, or 75.2 Deg F
The device ROM ID: 700000004B8F1010
The measured temperature: 24.5 Deg C, or 76.1 Deg F
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值