Olá meus Caros,

Estou desenvolvendo um projeto que preciso de dois medidores de pressão atmosférica com LCD, medindo simultaneamente e necessito suavizar suas leituras. Funciona de boa quando faço a leitura real e quando utilizo a suavização apenas para um sensor, quando coloco em ambos nenhum funciona.

Alguém poderia me dar um help????

Segue o código funcionando para suavização de um sensor apenas, preciso para os dois sensores:

const int numReadings = 10;

int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average

int inputPin = A0;

void setup()
{
// initialize serial communication with computer:
Serial.begin(9600);
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}

void loop() {
// subtract the last reading:
total= total - readings[index];

int ValorP = analogRead(A0);

float voltagemP = ValorP * (5 / 1023.0);
float milimetrosP = (voltagemP * 63.69) - 63.7;

// read from the sensor:
readings[index] = analogRead(milimetrosP);

// add the reading to the total:
total= total + readings[index];

// advance to the next position in the array:
index = index + 1;

// if we're at the end of the array...
if (index >= numReadings)
// ...wrap around to the beginning:
index = 0;

// calculate the average:
average = total / numReadings;

// send it to the computer as ASCII digits
lcd.setCursor(0, 0);
lcd.print("P: ");
lcd.print(average);
lcd.print("mmH2O ");


delay(1); // delay in between reads for stability
}

 

Exibições: 1104

As respostas para este tópico estão encerradas.

Respostas a este tópico

Angelo, suavizar quer dizer calcular a pressão media durante um determinado periodo - é isso?

Faça a leitura de um sensor e depois do outro. 

Nesse caso mude somente a entrada :

int inputPin = A0;

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço