Negative sine wave values using DC offset

изображение



void setup() {
  Serial.begin(115200);
}

void loop() {
  static unsigned long startTimestartTime = millis();

  // Check if 10 seconds have passed: //warm time?
  while (millis() - startTime < 10000);

 // Calculate the voltage based on the raw sensor value:
  float voltage = float(analogRead(A0) - 512) * 5.0 / 1024.0;

  // Print the voltage amplitude to the serial plotter:
  Serial.print(voltage, 3);
  Serial.println(" V");

  delay(10);
}
2 Likes