Making AC current with pin 11 I'm trying to make AC current (50Hz) with an Arduino Uno. It seems to be not working (or wrong code).

int up;
int down;
int out = 11;
void setup() {
  pinMode(out, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  for (up = 0; up &lt;= 255; up++) {
    analogWrite(out, up);
    delay(1);
  }
  for (down = 255; down &gt;= 0; down--) {
    analogWrite(out, down);
    delay(1);
  }
}


Update:


Now the code above is giving output voltage of 0-5V (getting increased from 0 to 5 and then decreased) not giving a negative cycle (-5V).
After setting the minimum delay of 1, the output wave is still half wave rectifier with frequency 2Hz.
Without delay LED is blinking so fast I don't know what's its frequency.


How do I make make 50Hz AC current a with negative cycle?
I ran your sketch and this is the output signal:



analogWrite produce a square wave.

As Majenko said, you have to add a low pass filter to get that sine wave.