# how to get sine plot from a transformer in arduino serial plotter

I am trying to get a sinusoidal(sine) wave in my serial plotter from a step down transformer using analogread but the frequency is changed from 50Hz to ~1Hz and the wave is coming very slowly....I am working on real time so i want real time data which is 50 Hz sine wave...delay >100 is not showing sine graph...plzzz help me
this is my code...
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
// print out the value you read:
Serial.println(sensorValue);
delay(100); // delay in between reads for stability
}

I am working on real time so i want real time data which is 50 Hz sine wave...delay >100 is not showing sine graph

Do you realize that 50Hz is 50 cycles per second?

Do you realize that a 100mS delay is 1/10th of a second (10Hz)?

Depending on your requirements, you may want to sample as fast as you can, but normally you sample at a known sample rate so that you can re-construct the analog waveform. You'll probably want to sample at 500Hz or more.* And if you want to be accurate, use the method from Blink Without Delay... The other program steps take some time to execute and if you use delay(), the time for the other steps will be added to the delay.

And, the Arduino can't directly read the negative half of a sine wave. If you put a sine wave directly into the an analog pin, half the readings will be zero and if the current isn't limited you might burn-up the Arduino.

* Sampling theory says you need a sample rate of at-least twice the rate of the sample you are reading (two samples per cycle). But for that to work, you need a reconstruction filter to re-create the sine wave.

Your delay puts you at 10 samples per second (max). Each other instruction takes a little bit of time to execute.

If you draw a 50 hz wave on paper and take ten evenly spaced measurements, you will get basically the same value. There is a little delay as your other code runs so it the value will gradually shift.

``````Serial.println(sensorValue);
``````

Say sensorValue is 1000.
To print 1000, plus carriage return and line feed is going to take over 6 ms at 9600 bits per second.
Now, with a 100 ms delay, that's OK because that'll be done in the background by interrupts.
But if you reduce the delay too much, you'll start running out of buffer space, and printing will delay your sketch.

It may be wise to run the interface at 115200 bits per second.