How can I make an AC analog voltage with Arduino? I am trying to create an AC voltage in Arduino. Until now I have only managed to get a square wave. How can this be achieved with Arduino?

If I try:

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);
  }
}


is it still pulsed DC?
You have a few options:


Use a low-pass filter to round the square wave's edges some so they look more AC-ish.
Use a low-pass filter and have your code create steps of voltage that look AC-ish by varying the PWM widths.
Use an external SPI DAC chip that you can control with more discrete levels to make smoother looking AC.
Look into Direct Digital Synthesis (DDC) to learn more. Google "analog via ddS", lots of hits.