narigenio.ino 1.14 KB
Newer Older
Cristiano Krug's avatar
Cristiano Krug committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* MQ-8 Hydrogen Gas Sensor Circuit with Arduino */

const int AOUTpin=0;//the AOUT pin of the hydrogen sensor goes into analog pin A0 of the arduino
const int DOUTpin=3;//the DOUT pin of the hydrogen sensor goes into digital pin D3 of the arduino
//const int ledPin=5;//the anode of the LED connects to digital pin D5 of the arduino

int limit;
int value;

void setup() {
Serial.begin(9600);//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()
{
value= analogRead(AOUTpin);//reads the analog value from the hydrogen sensor's AOUT pin
limit= digitalRead(DOUTpin);//reads the digital value from the hydrogen sensor's DOUT pin
//Serial.print("Hydrogen value: ");
Serial.println(value);//prints the hydrogen value
//Serial.print("Limit: ");
//Serial.print(limit);//prints the limit reached as either LOW or HIGH (above or underneath)
delay(60000);
//if (limit == HIGH){
//digitalWrite(ledPin, LOW);//if limit has been reached, LED turns on as status indicator
//}
//else{
//digitalWrite(ledPin, HIGH);//if threshold not reached, LED remains off
//}
}