# Void Setup error

**URL:** <https://forum.arduino.cc/t/void-setup-error/896628>\
**Category:** Programming\
**Created:** [August 17, 2021, 9:45pm UTC](https://forum.arduino.cc/t/void-setup-error/896628 "2021-08-17T21:45:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gablos](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gablos/32/664897_2.png) [@gablos](https://forum.arduino.cc/u/gablos)\
**Post date:** [August 17, 2021, 9:45pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/1 "2021-08-17T21:45:36Z")

</div>

When I try typing in my code, I get an error. Here it is:

exit status 1  
variable or field 'setup' declared void

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 17, 2021, 9:46pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/2 "2021-08-17T21:46:33Z")

</div>

Do you think it might help if we could see your code ?

Please follow the advice given in the link below when posting code . Use **code tags** when posting code here to make it easier to read and copy for examination

> [@How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code):
>
> See also [FAQ - Arduino Forum](https://forum.arduino.cc/faq) for general rules on forum behaviour and etiquette. Hello, Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…

---

<div class="post-metadata">

**Author:** ![gablos](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gablos/32/664897_2.png) [@gablos](https://forum.arduino.cc/u/gablos)\
**Post date:** [August 17, 2021, 9:47pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/3 "2021-08-17T21:47:29Z")

</div>

Sure, Here is my code:

const int buzzPin = 11;  
const int trigPin = 9;  
const int echoPin = 10;  
long duration;  
int distance;

void setup {  
pinMode(trigPin, OUTPUT);  
pinMode(echoPin, INPUT);  
Serial.begin(9600);  
pinMode(buzzPin, OUPUT);  
}

void loop() {  
// Setting up the Distance Sensor:  
digitalWrite(trigPin, LOW);  
delayMicroseconds(2);  
digitalWrite(trigPin, HIGH);  
delayMicroseconds(10);  
digitalWrite(trigPin, LOW);  
duration = pulseIn(echoPin, HIGH);  
distance = duration\*0.034/2;  
Serial.print("Distance: ");  
Serial.println(distance);

//Buzzer sound making

do {  
tone(buzzPin, distance, 1);  
}  
while(1);

}

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 17, 2021, 9:49pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/4 "2021-08-17T21:49:18Z")

</div>

Why do users choose to ignore the advice on posting code ?

**The easier you make it to read and copy your code the more likely it is that you will get help**

Please follow the advice given in the link I posted

---

<div class="post-metadata">

**Author:** ![gablos](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gablos/32/664897_2.png) [@gablos](https://forum.arduino.cc/u/gablos)\
**Post date:** [August 17, 2021, 9:53pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/5 "2021-08-17T21:53:48Z")

</div>

This is my setup:

void setup {  
pinMode(trigPin, OUTPUT);  
pinMode(echoPin, INPUT);  
Serial.begin(9600);  
pinMode(buzzPin, OUPUT);  
}

This is the error message:

Arduino: 1.8.15 (Windows Store 1.8.49.0) (Windows 10), Board: "Arduino Uno"

distanceMusic:8:6: error: variable or field 'setup' declared void

void setup {

```
  ^ ~~~~

```

distanceMusic:9:27: error: expected '}' before ';' token

pinMode(trigPin, OUTPUT);

```
                       ^

```

distanceMusic:10:10: error: expected constructor, destructor, or type conversion before '(' token

pinMode(echoPin, INPUT);

```
      ^

```

distanceMusic:11:3: error: 'Serial' does not name a type

Serial.begin(9600);

^ ~~~~~

distanceMusic:12:10: error: expected constructor, destructor, or type conversion before '(' token

pinMode(buzzPin, OUPUT);

```
      ^

```

distanceMusic:13:1: error: expected declaration before '}' token

}

^

exit status 1

variable or field 'setup' declared void

This report would have more information with  
"Show verbose output during compilation"  
option enabled in File -\> Preferences.

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [August 17, 2021, 9:57pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/6 "2021-08-17T21:57:30Z")

</div>

> [@gablos](#):
>
> void setup {

You need parenthesis after setup in order to make it a function definition instead of a variable definition:  
`void setup() {`  
You're already using the correct syntax for loop()...

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 17, 2021, 10:03pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/7 "2021-08-17T22:03:22Z")

</div>

@gablos are you deliberately ignoring the advice to use code tags when posting code and error messages ?

---

<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:** [December 15, 2021, 10:03pm UTC](https://forum.arduino.cc/t/void-setup-error/896628/8 "2021-12-15T22:03:32Z")

</div>

Closed on December 15, 2021, 10:03pm UTC

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