我试图用带有arduino的MQ-3酒精传感器创建项目。我已经将所有电缆连接到传感器和arduino,并且我也对其进行了编码。 但是当我上传它并查看串行监视器时,传感器显示出奇怪的值,我不知道出了什么问题。
这是代码:
const int ledPin=13;
const int AOUTpin = A0;
const int DOUTpin=2;
int limit;
int values;
void setup() {
Serial.begin(115200);//sets the baud rate
pinMode(DOUTpin, INPUT);//sets the pin as an input to the arduino
pinMode(ledPin, OUTPUT);//sets the pin as an output of the arduino
}
void loop() {
values= analogRead(AOUTpin);
limit= digitalRead(DOUTpin);
Serial.print("Alcohol value: ");
Serial.println(values);//prints the alcohol value
Serial.print("Limit: ");
Serial.print(limit);//prints the limit reached as either LOW or HIGH (above or underneath)
delay(100);
if (limit == HIGH){
digitalWrite(ledPin, HIGH);//if limit has been reached, LED turns on as status indicator
}
else{
digitalWrite(ledPin, LOW);//if threshold not reached, LED remains off
}
}
您知道这里有什么问题吗? 传感器太便宜还是已经坏了?