hey
this my code for arduino to read o2 sensor with pc monitor and led output
try!!!!
int analogInPin = A0; // Analog input pin that the LAMBDA is attached to
//const int analogOutPin = 9; // Analog output pin
int sensorValue = 0; // value read from LAMBDA
float outputValue = 0; // value output mV
int led1=13; // afr 12.5 0.86
int led2=12; // afr 13.2 0.90
int led3=11; // afr 13.8 0.93
int led4=10; // afr 14.3 0.97
int led5=9; // afr 14.4 0.98
int led6=8; // afr 14.7 1 STACHEO
int led7=7; // afr 1.25 18
void setup() {
pinMode(led1,OUTPUT); //ROUGE
pinMode(led2,OUTPUT); //ROUGE
pinMode(led3,OUTPUT); //ORANGE
pinMode(led4,OUTPUT); //ORANGE
pinMode(led5,OUTPUT); //VERTE
pinMode(led6,OUTPUT); //BLEU
pinMode(led7,OUTPUT); //BLANCHE
Serial.begin(9600); // initialize serial communications at 9600 bps:
Serial.println(" HONDA Lambda");
}
void loop() {
// read the analog in value:
sensorValue = analogRead(A0);
// map it to the range of the analog out:
outputValue = sensorValue*4.88;
//outputValue = map(sensorValue, 0, 1023, 0, 5000); //conversion de la valeur lue en tension en V
if (outputValue > 945) Serial.print(" Lambda= 0.80 "),Serial.print(" AFR 12 "),digitalWrite (led1, HIGH),digitalWrite (led2, HIGH);
else digitalWrite (led1, LOW),digitalWrite (led2, LOW);
if (outputValue > 900 && outputValue <= 945) Serial.print(" Lambda= 0.85 MAX POWER"), digitalWrite (led1, HIGH);
else digitalWrite (led1, LOW);
if (outputValue > 855 && outputValue <= 900) Serial.print(" Lambda= 0.90 RICH"),digitalWrite (led2, HIGH);
else digitalWrite (led2, LOW);
if (outputValue > 810 && outputValue <= 855) Serial.print(" Lambda= 0.93 ++Rich"),digitalWrite (led3, HIGH);
else digitalWrite (led3, LOW);
if (outputValue > 540 && outputValue <= 810) Serial.print(" Lambda= 0.97 +Rich"),digitalWrite (led4, HIGH);
else digitalWrite (led4, LOW);
if (outputValue > 225 && outputValue <= 540) Serial.print(" Lambda= 0.98 Low Rich"),digitalWrite (led5, HIGH);
else digitalWrite (led5, LOW);
if (outputValue > 180 && outputValue <= 225) Serial.print(" Lambda= 1 STACHEO 14.7 "),digitalWrite (led6,OUTPUT);
else digitalWrite(led6,LOW);
if (outputValue > 135 && outputValue <= 180) Serial.print(" Lambda= 1.02 learn");
if (outputValue > 90 && outputValue <= 135) Serial.print(" Lambda= 1.04 LEARN");
if (outputValue > 45 && outputValue <= 90) Serial.print(" Lambda= 1.15");
if (outputValue <= 45) Serial.print(" Lambda = 1.25 "),digitalWrite (led7, HIGH);
else digitalWrite (led7, LOW);
Serial.print(" (mV): ");
Serial.println(outputValue);
delay(200);