I'm trying to generate a sine wave on my Arduino micro. I used this code.
int Pin = 9;
void setup()
{
Serial.begin(9600);
pinMode(Pin, INPUT);
}
void loop()
{
float something = millis()/10000.0;
int value = 128.0 + 128 * sin( something * 2.0 * PI );
analogWrite(Pin,value);
}
I have a low pass filter at the output of the pin to smooth the wave. The problem is : I get a nice square wave with a duty cycle from 0 to 100%, but not a sine wave. Ideally, I'd like to set a frequency of 10 Hz. Can anyone tell me where I made a mistake ? Thanks a lot !!!