need help for precise analog signal reading

hi there
I m trying to read analog singnal voltage by arduino board.
Let's sat i want to read sinusoidal signal of 50Hz from function generator.
I have used this sketch

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

void loop() {
// read the analog input into a variable:
int analogValue = analogRead(0);
// print the result:
Serial.println(analogValue);
// wait 10 milliseconds for the analog-to-digital converter
// to settle after the last reading:
delay(10);
}
This code is working but it displays mostly values 0 and 1024
so whenever i tried to reconstruct this signal it displays triangular wave
instead of sine wave
What should i do??????
any help will be appreciated

You are reading a 50 Hz signal at a 100Hz sampling rate, this means that you are only getting 2 samples pr. "wave" of the signal.

This is too little to give anything that resembels the original waveform.

Try to shorten the delay.

EDIT:

And also with a shorter delay you should probably increase the baudrate on the serial connection.

Don't put a delay in the built in A/D will go at a much faster rate.
Also don't print inside the loop, that takes a different amount of time for each sample as the number consists of a different number of digits.

Try reading the samples into an array for so many samples and then print them out to see your sin wave.

hey thanx for guidance
i have modified program in this way
void setup() {
Serial.begin(9600);
}

void loop() {
int analogValue[]={};
{ for(int i=0;i<=8;i++)
analogValue*=analogRead(0);*

  • }*
  • Serial.print("\n");*
  • for(int j=0;j<=8;j++){*
  • Serial.print(analogValue[j]);*
    }
    }
    is this better or completely wrong way?
    because i am not getting any output at serial window
for (int count=0; count <= 199; count++){   // reads 200 values for waveform
      ctpinvalue[count] = analogRead(ctPin);    // Pin 0 Current transformer
       delayMicroseconds(50);
    } // end of count loop

Since I'm in a good mood here's code lifted out of one of my sketches that measuures 50hz AC. No print statements, thats done in an entirely seperate lump of code.

It ultimately produces this graph, which varies between a beautiful sine wave and a spikey mess depending on load and power factor etc :

Its approximately 2 cycles which equates to about a 25th of a second......

 int analogValue[]={};

An array of zero entries is not much use for holding data

yes change:-
void loop() {
int analogValue[]={};

to :-
int analogValue[8];
void loop() {

hey mike its still not working
i am trying apply 50hz signal from function generator with peak to peak value of 5volt.i have connect one terminal to analog pin specified in the program and ground to analog reference.i have also try this with increase in baudrate to 38400.wht should i do ??
can we print this values serially?

ground to analog reference

Wouldn't that just make all your readings zero?