Programming Error - need help!!!

Hi, so I have been trying this code out (which was given by our professor for us to try) :

int led[] = {13,12,11,10,9};
int fadeamount = 5;
void setup() {
pinMode(led, OUTPUT);
}

void loop() {
for(int x = 0; x<5; x++)
{
for(int brightness=0; brightness < 255; brightness + 5)
{
  analogWrite(led[x],brightness);
  delay(30);
   
}
analogWrite(led,0);
for(int brightness=255; brightness>=0; brightness=brightness - 5)
{
  analogWrite(led[x],brightness);
  delay(30);
}
analogWrite(led[x],0);
}
}

Though these codes are correct, for some reason it just doesn't work. I'm trying to fade out 5 LEDs one by one.

Somehow, this error comes up when I compile it. It uploads but then the effect doesn't show in the Arduino board. I'm using Arduino UNO.

C:\Users\acer\Documents\Arduino\FADE_ROW\FADE_ROW.ino: In function 'void setup()':

C:\Users\acer\Documents\Arduino\FADE_ROW\FADE_ROW.ino:5:20: warning: invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' [-fpermissive]

pinMode(led, OUTPUT);

^

In file included from sketch\FADE_ROW.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:133:6: note: initializing argument 1 of 'void pinMode(uint8_t, uint8_t)'

void pinMode(uint8_t, uint8_t);

^~~~~~~

Can anyone help me? have been trying to search the net for solution but no luck.

Your code does not really look like that, does it ?

Please read read this before posting a programming question and follow the advice about posting code

Is led an array or just an ordinary int?

Your error is caused by trying to set the pinMode of an array of pins in one step. You must set them individually as you must also do with analogWrite()

brightness+5

Oops

UKHeliBob:
Your error is caused by trying to set the pinMode of an array of pins in one step. You must set them individually as you must also do with analogWrite()

can you further elaborate? I'm a beginner here, sorry :frowning:

GypsumFantastic:
Is led an array or just an ordinary int?

hi yes, Led is an array

mikaaaa:
hi yes, Led is an array

You cannot set the pinMode() of an array of pin numbers with just a single statement

can you further elaborate? I'm a beginner here, sorry

First post your code correctly

UKHeliBob:
You cannot set the pinMode() of an array of pin numbers with just a single statement
First post your code correctly

I have fixed it now. Sorry about that.

No, you need a loop for the pinModes

And fix the brightness + 5 problem

UKHeliBob:
And fix the brightness + 5 problem

Thank you. Took me a while to understand what you were trying to say (sorry). Will do set the pinMode() for the array individually, and fix the brightness code too.