임베디드 보드/아두이노

디지털 차압 게이지 - 아두이노 측정

ZEROWIN.TECH 2020. 7. 31. 11:10
728x90

기체 또는 액체의 압력을 측정합니다.

차압게이지는 엑체 또는 가스의 흐름을 측정합니다.

 

 

 

 

프로그래밍

아날로그 입력을 받아 시리얼 모니터로 값을 출력합니다.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

// 0.0 - 775
// 1.6 - 830
#define LOW_LIMIT 775
#define HIGH_LIMIT (830)
#define POINT_RANGE 1.6

int DataArray[10] = { 0, };
int loopCount = 0;
float point = 0.0;
void loop() {
  // put your main code here, to run repeatedly:
  int value = analogRead(A0);
  if(value < LOW_LIMIT) value = 0;
  else value = value-LOW_LIMIT;
  
  if(loopCount == 0) {
    for(int i = 0; i < 10; i++)
    {
      DataArray[i] = value;
    }
  }
  
  DataArray[loopCount % 10] = value;
  loopCount += 1;

  int total = 0;
  float average = 0;
  for(int i = 0; i < 10; i++)
  {
    
    total += DataArray[i];
  }

  average = total / 10;

  point = average / (HIGH_LIMIT-LOW_LIMIT) * POINT_RANGE;

  Serial.print(value);
  Serial.print(',');
  Serial.print(average);
  Serial.print(',');
  Serial.println(point);
  delay(100);
}

 

디지털 차압 게이지