How does AnalogWrite work?

I'm trying to to direct drive an 8x8 ledMatrix and I can't seem to figure out how to use the analog pins. I modified the blink sketch and am trying to use the analog signals.

/*
 Analog Blink
 This is an a wire connected from the Analog pin 1
 to an led whose other pin is grounded.

 */

int ledPin =  15;    // Analog pin 1
int temp;            //value place holder
int vcc = 255;     // Set value to 5v equivalent
int gnd = 0;        // Set Value to Ground equivalent
// The setup() method runs once, when the sketch starts

void setup()   {                
       
}

// the loop() method runs over and over again, 
// as long as the Arduino has power

void loop()                     
{
  temp = analogRead(vcc);
  analogWrite(ledPin, temp);   // set the LED on
  delay(100);                  // wait for a second
  
  temp = analogRead(gnd);
  analogWrite(ledPin, temp);    // set the LED off
  delay(100);                  // wait for a second
}

You forgot to use the pinMode to set them as outputs:

pinMode(ledpin, OUTPUT); //this belongs in your setup()

Without that, the most your pin will output is like 1.1v or something very low!

ALSO:

int ledPin = 15; // Analog pin 1 int temp; //value place holder int vcc = 255; // Set value to 5v equivalent int gnd = 0; // Set Value to Ground equivalent

When you're calling analogRead, you're doing this: analogRead(255); // you need 0-5, 255 isn't an arduino pin!! analogRead(0); // This will work, reading analog pin 0

I think you were looking to use them to turn on and off the LEDs to their full values, in that case, you want to Write those values to the leds, rather than Read them.

analogWrite(ledpin, vcc); // will turn on the LED full brightness (same as analogWrite(ledpin, 255); analogWrite(ledpin, gnd);// will turn off the LED. (same as analogWrite(0))

direct drive an 8x8 ledMatrix and I can't seem to figure out how to use the analog pins

You can't drive an 8X8 matrix directly from an arduino, ther is not enough current drive.

You don't use analogue write to drive a matrix. That produces a PWM output at about 500Hz. For info on PWM see:- http://www.thebox.myzen.co.uk/Tutorial/PWM.html

For driving a matrix see:- http://www.thebox.myzen.co.uk/Hardware/Econo_Monome.html

Thanks to the previous response I was able to figure out the analogWrite. I see what you mean about the current but I'm trying to work the sample from the following page a different way:

http://www.arduino.cc/playground/Main/DirectDriveLEDMatrix

In the end I will use a max7221 to drive the led 8x8 matrix and then hopefully daisy chain a few. So far I am still trying to figure out the sample maxfunctions from the arduino page but all is a work in progress. Any advice would help. Thanks