arduino控制雨滴传感器
生活随笔
收集整理的這篇文章主要介紹了
arduino控制雨滴传感器
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
一、實(shí)物連接
二、代碼實(shí)現(xiàn)
const int analogPin=A0; //the AO of the module attach to A0 const int digitalPin=7; //D0 attach to pin7 const int ledPin=13; //pin 13 built-in led int Astate=0; //store the value of A0 boolean Dstate=0; //store the value of D0void setup() {pinMode(ledPin,OUTPUT); //set the ledPin as OUTPUT pinMode(digitalPin,INPUT); //set digitalPin as INPUTSerial.begin(9600); //initialize the serial monitor }void loop() {Astate=analogRead(analogPin); //read the value of A0Serial.print("A0: ");Serial.println(Astate); //print the value in the serial monitorDstate=digitalRead(digitalPin); //read the value of D0Serial.print("D0: ");Serial.println(Dstate);if(Dstate==HIGH) {digitalWrite(ledPin,LOW);}else //if the value of D0 is LOW{digitalWrite(ledPin,HIGH); //turn on the led} }總結(jié)
以上是生活随笔為你收集整理的arduino控制雨滴传感器的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Delphi XE5实现减少编译出来的程
- 下一篇: 三角形带优化库nvtrisrip的使用