大神求解
2017-08-271.2万
AI 快速预览详细
本文是一篇关于土壤湿度传感器的入门教程,适用于零基础的新手。文章详细讲解了如何将传感器连接到Arduino板,并提供了具体的代码示例。通过简单的步骤,读者可以轻松读取土壤湿度值。传感器的输出范围为0~950,其中0~300表示干燥土壤,300~700表示湿润土壤,700~950表示在水中。
|
新手第一次接触土壤湿度传感器,请大神讲解一下。谢谢! /* # Example code for the moisture sensor # Editor : Lauren # Date : 13.01.2012 # Version : 1.0 # Connect the sensor to the A0(Analog 0) pin on the Arduino board # the sensor value description # 0 ~300 dry soil # 300~700 humid soil # 700~950 in water */ void setup(){ Serial.begin(57600); } void loop(){ Serial.print("Moisture Sensor Value:"); Serial.println(analogRead(0)); delay(100); } |




前者输出一行文字:“湿度传感器数值为:”
后者读取接在模拟传感器输入引脚A0上的传感器数值。analogRead=模拟+读取