ocrobot mango(Arduino兼容控制板) | 1块 |
面包板 | 1块 |
面包板专用跳线 | 1盒 |
LM35D温度传感器 (千万别与三极管弄混了,温度传感器很贵的) | 1枚 |
数据线 | 1根 |
/*
作者:极客工坊-迷你强
时间:2012年6月26日
IDE版本号:1.0.1
发布地址:www.geek-workshop.com
作用:使用arduino模拟口测量室内温度
*/
void setup() {
Serial.begin(9600); //使用9600速率进行串口通讯
}
void loop() {
int n = analogRead(A0); //读取A0口的电压值
float vol = n * (5.0 / 1023.0*100); //使用浮点数存储温度数据,温度数据由电压值换算得到
Serial.println(vol); //串口输出温度数据
delay(2000); //等待2秒,控制刷新速度
}
欢迎光临 智能创客,中国最大的极客空间,智能平台,免费教学,视频教程,手把手教你创造儿时梦想! (http://luntan.znck007.com/) | Powered by Discuz! X3.2 |