void setup()
{
Serial.begin(9600); // sets the serial port to 9600
pinMode(sensorPin, INPUT);
}
void loop()
{
sensorValue = analogRead(sensorPin); // read analog input pin 9
Serial.print(sensorValue); // prints the value read
Serial.print(" "); // prints a space between the numbers
delay(1000); // wait 100ms for next reading
}
pinMode(9, INPUT) will set Digital I/O pin 9 to be a digital input.
analogRead(9) will read Analog Input pin 9 ?!? Do you have an Arduino that has more than the usual 6 analog input pins (0-5)?!?
From the readings it appears that you may have a bad connection somewhere or some bad noise in the input. When you hook a multimeter between the input pin and ground do you get a nice steady voltage reading?
thx again, and i have checked immediately, i have gaineded steady voltage reading, and i have also checked the data sheet, http://www.winsensor.com/english/products/sms/jsq.asp?filename=MQ7.pdf, so, i am sure i am supplying 5.2 - 5.4 voltage to the circuit correctly, and the readings are still not ok ...
btw, is it necessary to pre-heat this sensor? i have found one point in the datasheet saying that it takes 2 days to re-heat the sensor,
so does it mean i have to supply 5 volt to the circuit for 2 days for reasonable readings?
sorry, i have a fairly ok knowledge only, thx for your patience, thxthxthx
btw, is it necessary to pre-heat this sensor? i have found one point in the datasheet saying that it takes 2 days to re-heat the sensor,
so does it mean i have to supply 5 volt to the circuit for 2 days for reasonable readings?
IIRC it is needed for calibration (only once). To use this sensor you have to apply 60sec 5Volts and then 90sec 1.4 Volts. Can be done with PWM. Measure at the end of a 1.4V cycle. So one reading every 2.5 minutes is possible.