How To Smooth Out Any Analog Signal? Motion Filtering & Signal Smoothing / Averaging With Arduino

Поделиться
HTML-код
  • Опубликовано: 1 ноя 2024

Комментарии • 5

  • @Mruser010user
    @Mruser010user 5 месяцев назад +5

    const int numReadings = 1 ;
    int readings[numReadings];
    int readIndex= 0;
    int total = 0;
    int average = 0;
    void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    for (int thisReading = 0; thisReading < numReadings; thisReading++){
    readings[thisReading]= 0;
    }
    }
    void loop() {
    // put your main code here, to run repeatedly:
    total = total-readings[readIndex];
    readings[readIndex] = analogRead(A0);
    Serial.print (readings[readIndex]);
    Serial.print(",");
    total = total+readings[readIndex];
    readIndex = readIndex+1;
    if(readIndex >= numReadings)
    {
    readIndex =0;
    }
    average = total/numReadings;
    Serial.println(average);
    delay(15);
    }

  • @Mruser010user
    @Mruser010user 5 месяцев назад +1

    tanks ,It Works like magic

  • @HassanEidMohamed-w1v
    @HassanEidMohamed-w1v 10 месяцев назад +1

    please send the code arduino

    • @Mruser010user
      @Mruser010user 5 месяцев назад +1

      copie the code from the video

    • @Mruser010user
      @Mruser010user 5 месяцев назад +1

      const int numReadings = 1 ;
      int readings[numReadings];
      int readIndex= 0;
      int total = 0;
      int average = 0;
      void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600);
      for (int thisReading = 0; thisReading < numReadings; thisReading++){
      readings[thisReading]= 0;
      }
      }
      void loop() {
      // put your main code here, to run repeatedly:
      total = total-readings[readIndex];
      readings[readIndex] = analogRead(A0);
      Serial.print (readings[readIndex]);
      Serial.print(",");
      total = total+readings[readIndex];
      readIndex = readIndex+1;
      if(readIndex >= numReadings)
      {
      readIndex =0;
      }
      average = total/numReadings;
      Serial.println(average);
      delay(15);
      }