# 'pinMode' does not name a type

**URL:** <https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253>\
**Category:** Programming\
**Created:** [March 20, 2022, 6:41am UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253 "2022-03-20T06:41:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![trxwalker](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@trxwalker](https://forum.arduino.cc/u/trxwalker)\
**Post date:** [March 20, 2022, 6:41am UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/1 "2022-03-20T06:41:39Z")

</div>

Hello! So, recently, I wanted to combine 3 codes. But I have an error with pinMode. If someone helps me, Thank you so much!! This is the code:

```cpp
/*
  Fade

  This example shows how to fade an LED on pin 9 using the analogWrite()
  function.

  The analogWrite() function uses PWM, so if you want to change the pin you're
  using, be sure to use another PWM capable pin. On most Arduino, the PWM pins
  are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fade
*/

int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
pinMode = (LED_BUILTIN, OUTPUT);
const int sensorPin = 0;
const int ledPin = 10;
int lightCal;
int lightVal;

void setup{
  // We'll set up the LED pin to be an output.
  pinMode(ledPin, OUTPUT);
  lightCal = analogRead(sensorPin);
   pinMode =(LED_BUILTIN, OUTPUT);
    pinMode = (led, OUTPUT);
    
}

void loop{
  pr()
  blink()
  fade()
}

void pr()
{
  //Take a reading using analogRead() on sensor pin and store it in lightVal
  lightVal = analogRead(sensorPin);

  //if lightVal is less than our initial reading (lightCal) minus 50 it is dark and
  //turn pin 9 HIGH. The (-50) part of the statement sets the sensitivity. The smaller
  //the number the more sensitive the circuit will be to variances in light.
  if (lightVal < lightCal - 50)
  {
    digitalWrite(9, HIGH);
  }

  //else, it is bright, turn pin 9 LOW
  else
  {
    digitalWrite(9, LOW);
  }

}
// the loop function runs over and over again forever
void blink() {
  digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(1000); // wait for a second
  digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
  delay(1000); // wait for a second
}

// the loop routine runs over and over again forever
void fade() {
  // set the brightness of pin 9:
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

```

and the error is

Fade:19:1: error: 'pinMode' does not name a type  
pinMode = (LED\_BUILTIN, OUTPUT);  
^ ~~~~~~  
Fade:25:6: error: variable or field 'setup' declared void  
void setup{  
^ ~~~~  
Fade:27:26: error: expected '}' before ';' token  
pinMode(ledPin, OUTPUT);  
^  
Fade:28:3: error: 'lightCal' does not name a type  
lightCal = analogRead(sensorPin);  
^ ~~~~~~~  
Fade:29:4: error: 'pinMode' does not name a type  
pinMode =(LED\_BUILTIN, OUTPUT);  
^ ~~~~~~  
Fade:30:5: error: 'pinMode' does not name a type  
pinMode = (led, OUTPUT);  
^ ~~~~~~  
Fade:32:1: error: expected declaration before '}' token  
}  
^  
exit status 1  
'pinMode' does not name a type

any ideea? The error messages are in void setup(). Or so I think

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [March 20, 2022, 6:43am UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/2 "2022-03-20T06:43:02Z")

</div>

> [@trxwalker](#):
>
> `pinMode = (LED_BUILTIN, OUTPUT);`

Put the above in **setup( )**

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [March 20, 2022, 7:26am UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/3 "2022-03-20T07:26:18Z")

</div>

> [@LarryD](#):
>
> Put the above in **setup( )**

And lose the "=" !

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [March 20, 2022, 8:30am UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/4 "2022-03-20T08:30:00Z")

</div>

See [the pinMode function reference.](https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/)

---

<div class="post-metadata">

**Author:** ![er\_name\_not\_found](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/er_name_not_found/32/647693_2.png) [@er\_name\_not\_found](https://forum.arduino.cc/u/er_name_not_found)\
**Post date:** [March 20, 2022, 6:41pm UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/5 "2022-03-20T18:41:03Z")

</div>

> [@trxwalker](#):
>
> `pinMode = (LED_BUILTIN, OUTPUT);`

pinmode is a function, not a variable. In the parentheses go the parameters.

```arduino
pinMode(LED_BUILTIN, OUTPUT);

```

---

<div class="post-metadata">

**Author:** ![johnwasser](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnwasser/32/214270_2.png) [@johnwasser](https://forum.arduino.cc/u/johnwasser)\
**Post date:** [March 20, 2022, 6:56pm UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/6 "2022-03-20T18:56:37Z")

</div>

And change "void setup{" to "void setup() {". The parens tell the compiler you are declaring a function.

And change:

```cpp
  pinMode = (LED_BUILTIN, OUTPUT);
  pinMode = (led, OUTPUT);

```

to

```cpp
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(led, OUTPUT);

```

And change "void loop{" to "void loop() {", same as for setup.

And add ';' after each of these three statements:

```cpp
  pr()
  blink()
  fade()

```

Then your sketch will compile.

---

<div class="post-metadata">

**Author:** ![trxwalker](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@trxwalker](https://forum.arduino.cc/u/trxwalker)\
**Post date:** [April 14, 2022, 4:05pm UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/7 "2022-04-14T16:05:34Z")

</div>

Thank you very much! You helped me a lot!!!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [October 11, 2022, 4:05pm UTC](https://forum.arduino.cc/t/pinmode-does-not-name-a-type/971253/8 "2022-10-11T16:05:50Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
