# Variable not declared in this scope,but to me it is???

**URL:** <https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876>\
**Category:** Programming\
**Created:** [February 25, 2020, 10:48pm UTC](https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876 "2020-02-25T22:48:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erikthegamer](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/erikthegamer/32/307582_2.png) [@Erikthegamer](https://forum.arduino.cc/u/Erikthegamer)\
**Post date:** [February 25, 2020, 10:48pm UTC](https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876/1 "2020-02-25T22:48:51Z")

</div>

I am designing code to control 2 light strips(cold white and warm white) with pushbuttons and an LCD (Using PT6961, link to the library can be found [here](https://web.archive.org/web/20161127234429/http://gtbtech.com:80/?p=528)). When adding the debouncing code to it everything broke...As always(at least for me) the help dialog is useless.  
Here is my code:

> **[The Code - Pastebin.com](https://pastebin.com/xiLVDHth)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

The error message:

```cpp
Arduino: 1.8.9 (Mac OS X), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"

/Users/user/Desktop/led_controller/led_controller.ino: In function 'void loop()':
led_controller:112:37: error: 'cold_white_pwm_increase' was not declared in this scope
            cold_white_pwm_increase(); //Goto function
                                    ^
led_controller:127:37: error: 'warm_white_pwm_increase' was not declared in this scope
            warm_white_pwm_increase();
                                    ^
led_controller:142:37: error: 'cold_white_pwm_decrease' was not declared in this scope
            cold_white_pwm_decrease();
                                    ^
led_controller:157:37: error: 'warm_white_pwm_decrease' was not declared in this scope
            warm_white_pwm_decrease();
                                    ^
led_controller:172:26: error: 'all_increase' was not declared in this scope
            all_increase();
                          ^
led_controller:187:26: error: 'all_decrease' was not declared in this scope
            all_decrease();
                          ^
led_controller:194:32: error: a function-definition is not allowed here before '{' token
 void cold_white_pwm_increase() {
                                ^
led_controller:339:1: error: expected '}' at end of input
 }
 ^
exit status 1
'cold_white_pwm_increase' was not declared in this scope

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

```

I know it is really simple to debug this, but I'm unable to...

---

<div class="post-metadata">

**Author:** ![PerryBebbington](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/perrybebbington/32/238766_2.png) [@PerryBebbington](https://forum.arduino.cc/u/PerryBebbington)\
**Post date:** [February 25, 2020, 10:52pm UTC](https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876/2 "2020-02-25T22:52:16Z")

</div>

Please post your code on this web site, not expect us to follow a link to somewhere else. Note it is essential to post YOUR code exactly as it is in the IDE when it produces errors.

I notice that you have other errors, specifically regarding the use of {}

Thanks.

---

<div class="post-metadata">

**Author:** ![slipstick](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@slipstick](https://forum.arduino.cc/u/slipstick)\
**Post date:** [February 25, 2020, 11:22pm UTC](https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876/3 "2020-02-25T23:22:55Z")

</div>

You need to end loop() with a suitably placed } BEFORE you start defining the other functions.

Steve

---

<div class="post-metadata">

**Author:** ![Erikthegamer](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/erikthegamer/32/307582_2.png) [@Erikthegamer](https://forum.arduino.cc/u/Erikthegamer)\
**Post date:** [February 26, 2020, 6:13am UTC](https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876/4 "2020-02-26T06:13:37Z")

</div>

Oh...I see now, I looked at code and it must be I removed it it accidentally. Works like a champ. Thank you!!!

---

<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:** [February 26, 2020, 5:37pm UTC](https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876/5 "2020-02-26T17:37:11Z")

</div>

The key errors are these two:

```cpp
led_controller:194:32: error: a function-definition is not allowed here before '{' token
 void cold_white_pwm_increase() {
                                ^
led_controller:339:1: error: expected '}' at end of input
 }
 ^

```

The second one means there is a '}' missing somewhere. The first one usually means that you are missing a '}' (or have an extra '{') in the previous function declaration.

---

<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:** [May 6, 2021, 12:20am UTC](https://forum.arduino.cc/t/variable-not-declared-in-this-scope-but-to-me-it-is/638876/6 "2021-05-06T00:20:35Z")

</div>

Closed on May 6, 2021, 12:20am UTC


