I've uploaded the code to arduino Uno but serial monitor is just displaying value 0 all the time. I'm attaching my code below. Please let me know if there are any errors.
Ts = 1 / fs;
I'm not sure what the compiler will do, but I think it divides integer '1' by integer '400'. That is '0', and convert it to float, so Ts is 0.0.
I suggest to do everything in float. The loop with 'n' is an integer, but you cast that to a float with: (float) n
(While I was typing this, Arrch and luisilva wrote the same)
I have one more question. After making the corrections, the output in the serial monitor is limited to two decimal points only. But I need 5-6 decimal points. Is there anything that I should do additionally.?
Two things. One, the Serial.print() method that deals with floats takes an optional second argument to define the number of digits after the decimal point to print. Two, you need to adjust your expectations. 5 or 6 decimal places on an Arduino is unrealistic.