• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 读取ADC并转化为温度demo
2
3## 购买外设
4
5[LM35线性模拟温度传感器](https://wiki.dfrobot.com.cn/_SKU_DFR0023_LM35%E7%BA%BF%E6%80%A7%E6%A8%A1%E6%8B%9F%E6%B8%A9%E5%BA%A6%E4%BC%A0%E6%84%9F%E5%99%A8)
6
7![](../figures/adc_DFRobot_LM35.jpg)
8
9## 连线
10
11- 红线 -- 3.3V
12- 黑线 -- GND
13- 蓝线 -- ADC_1
14
15连线实物图
16
17![](../figures/adc_demo.png)
18
19## 编译
20
211) 修改 `vendor/unionman/unionpi_tiger/sample/BUILD.gn`
22
23```gn
24import("//build/ohos.gni")
25
26group("sample_group") {
27  deps = [ "hdf:hdf",
28           "hardware/adc:adc_test" # 添加这句话]
29}
30```
31
322. 编译 打包 见https://gitee.com/openharmony/device_board_unionman/tree/master/unionpi_tiger#%E7%BC%96%E8%AF%91%E4%B8%8E%E8%B0%83%E8%AF%95
33
343. 打开`cmd窗口`利用hdc_std工具传输文件 (获取hdc_std工具可参考https://ost.51cto.com/posts/10190)
35
36   `hdc_std file send Z:\master\out\unionpi_tiger\packages\phone\system\bin\adc_test data/`
37
384. 与开发板交互
39
40   `hdc_std shell`
41
425. 修改权限
43`chmod 777 data/adc_test`
44
456. 运行!
46`./data/adc_test`
47
48## 结果
49
50![](../figures/adc_result.png)
51