Newer
Older
RespDoppler / DopplerSignal / DopplerSignal.ino


const int DOPPLER_0_PIN = A0;
const int DOPPLER_1_PIN = A1;
// const int MEAN_SIZE = 10;
int gDoppler0 = 0;  // value read from the doppler 0
int gDoppler1 = 0;  // value read from the doppler 1
// int gSum0 = 0;
// int gSum1 = 0;
struct repeating_timer st_timer;

/* タイマー割り込み処理 */
bool Timer(struct repeating_timer *t) {
  gDoppler0 = analogRead(DOPPLER_0_PIN);
  gDoppler1 = analogRead(DOPPLER_1_PIN);

  Serial.print(millis());
  Serial.print(",");
  Serial.print(gDoppler0);
  Serial.print(",");
  Serial.println(gDoppler1);

  return true;
}

void setup() {
  Serial.begin(115200);
  add_repeating_timer_us(-10000, Timer, NULL, &st_timer);
}

void loop() {
  // gSum0 = 0;
  // gSum1 = 0;
  // for (int i = 0; i < MEAN_SIZE; i++){
  //   gDoppler0 = analogRead(DOPPLER_0_PIN);
  //   gDoppler1 = analogRead(DOPPLER_1_PIN);
  //   gSum0 += gDoppler0;
  //   gSum1 += gDoppler1;
  //   delay(1);
  // }

  // // print the results to the Serial Monitor:
  // Serial.print((float)gSum0 / MEAN_SIZE);
  // Serial.print(",");
  // Serial.println((float)gSum1 / MEAN_SIZE);
}