Hello
I have problem getting sine wave. I gave 10Hz AC signal to A0 and I expected to see a clean sine wave on sketch plotter,but my graph was showing me that waves are clipped off from the top (shown below).
and this is my code:
void setup(){
Serial.begin(9600);
}
void loop(){
int sensorValue = analogRead(A0);
float a=min(sensorValue,0);
float b=max(sensorValue,5);
float voltage = sensSine(sensorValue,0,1023,a,b);
Serial.println(voltage);
delay(10);
}
float sensSine(float x,long in_min,long in_max,long out_min,long out_max)
{
long map(long x, long in_min, long in_max, long out_min, long out_max);
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
please help me to fix my code and be able to see clean sine wave.
Thank you
