Difference between revisions of "Oxygen Sensor"
Qian.zhang (talk | contribs) |
Qian.zhang (talk | contribs) (→Usage) |
||
| Line 13: | Line 13: | ||
== Usage == | == Usage == | ||
| + | <syntaxhighlight lang="c"> | ||
| + | |||
| + | #include <math.h> | ||
| + | const int buzzerPin=3; //Connect the Buzzer module to Pin3, Digital 3 | ||
| + | float thresholdVoltage= 1.84; //The treshold for which the Buzzer should sound. | ||
| + | void setup() | ||
| + | { | ||
| + | Serial.begin(9600); //Start the Serial connection | ||
| + | pinMode(buzzerPin,OUTPUT); //Set the LED on Digital 12 as an OUTPUT | ||
| + | |||
| + | } | ||
| + | void loop() | ||
| + | { | ||
| + | |||
| + | float sensorValue; | ||
| + | float sensorVoltage; | ||
| + | sensorValue = analogRead(A2); | ||
| + | sensorVoltage =(sensorValue/1024)*5.0; | ||
| + | |||
| + | if(sensorVoltage<thresholdVoltage) | ||
| + | { | ||
| + | digitalWrite(buzzerPin,HIGH); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | digitalWrite(buzzerPin,LOW); | ||
| + | } | ||
| + | sensorVoltage = sensorVoltage/101*1000; | ||
| + | Serial.println("the output voltage is:"); | ||
| + | |||
| + | Serial.print(sensorVoltage); | ||
| + | Serial.println("mV"); | ||
| + | delay(1000); | ||
| + | } | ||
| + | |||
| + | </syntaxhighlight> | ||
== Recources == | == Recources == | ||
Revision as of 01:37, 31 October 2014
Contents
Introduction
Linker Oxygen sensor module uses ME series O2 sensor, and have low consumption , small size, high sensitivity , wide range of linearity , and better anti-jamming capacity, good reproducibility, stability and reliability ect advantage . It is electrochemical sensor widely suits for mine, industry and environmental protection field ect.
Schematic
Usage
<syntaxhighlight lang="c">
- include <math.h>
const int buzzerPin=3; //Connect the Buzzer module to Pin3, Digital 3 float thresholdVoltage= 1.84; //The treshold for which the Buzzer should sound. void setup() {
Serial.begin(9600); //Start the Serial connection pinMode(buzzerPin,OUTPUT); //Set the LED on Digital 12 as an OUTPUT
} void loop() {
float sensorValue; float sensorVoltage; sensorValue = analogRead(A2); sensorVoltage =(sensorValue/1024)*5.0;
if(sensorVoltage<thresholdVoltage)
{
digitalWrite(buzzerPin,HIGH);
}
else
{
digitalWrite(buzzerPin,LOW);
}
sensorVoltage = sensorVoltage/101*1000;
Serial.println("the output voltage is:");
Serial.print(sensorVoltage); Serial.println("mV"); delay(1000); }
</syntaxhighlight>