赞
踩
PM2.5传感器
arduino uno
一个220uf的电容,一个150欧的电阻
引脚说明,从左到右
VCC GND LED GND A0 VCC
左边的第一个线接电阻和电容
电容大小:220uf
电阻大小:150欧
- int dustPin=0;//A0引脚
- float dustVal=0;
- int ledPower=2;//引脚
- int delayTime=280;
- int delayTime2=40;
- float offTime=9680;
- void setup(){
- Serial.begin(9600);
- pinMode(ledPower,OUTPUT);
- pinMode(dustPin, INPUT);
- }
-
- void loop(){
- // ledPower is any digital pin on the arduino connected to Pin 3 on the sensor
- digitalWrite(ledPower,LOW);
- delayMicroseconds(delayTime);
- dustVal=analogRead(dustPin);
- delayMicroseconds(delayTime2);
- digitalWrite(ledPower,HIGH);
- delayMicroseconds(offTime);
- delay(1000);
- if (dustVal>36.455)
- Serial.println((float(dustVal/1024)-0.0356)*120000*0.035);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。