ledPin was not declared in this scope, unsure why?

I have recently brought an ESP 32 WROOM, and ive been watching a video by Drone workshop, i copied his blink sketch from the article Getting Started with the ESP32 - Using the Arduino IDE
when i try to upload it the IDE tells me ledPin was not declared in this scope, however I have been staring at this for nearly 10 minutes and it looks fine to me, ill show a print screen here as it is a very short sketch and you can see all the code in one screenshot.

here is the complete error message:

Arduino: 1.8.12 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None"

<command-line>: error: expected unqualified-id before numeric constant
C:\Users\NicholasNG\Documents\Arduino\Classic_bluetooth_ESP_32\Classic_bluetooth_ESP_32.ino:1:3: note: in expansion of macro 'ESP32'
   ESP32 Blink
   ^~~~~
C:\Users\NicholasNG\Documents\Arduino\Classic_bluetooth_ESP_32\Classic_bluetooth_ESP_32.ino: In function 'void setup()':
Classic_bluetooth_ESP_32:16:13: error: 'ledPin' was not declared in this scope
     pinMode(ledPin, OUTPUT);
             ^~~~~~
C:\Users\NicholasNG\Documents\Arduino\Classic_bluetooth_ESP_32\Classic_bluetooth_ESP_32.ino:16:13: note: suggested alternative: 'lldiv'
     pinMode(ledPin, OUTPUT);
             ^~~~~~
             lldiv
C:\Users\NicholasNG\Documents\Arduino\Classic_bluetooth_ESP_32\Classic_bluetooth_ESP_32.ino: In function 'void loop()':
Classic_bluetooth_ESP_32:25:18: error: 'ledPin' was not declared in this scope
     digitalWrite(ledPin, HIGH);
                  ^~~~~~
C:\Users\NicholasNG\Documents\Arduino\Classic_bluetooth_ESP_32\Classic_bluetooth_ESP_32.ino:25:18: note: suggested alternative: 'lldiv'
     digitalWrite(ledPin, HIGH);
                  ^~~~~~
                  lldiv
exit status 1
'ledPin' was not declared in this scope

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

very odd, under board in tools I use "ESP 32 devmodule" there are also a variety of new setting that appear when using the ESP 32 and ill show an image of my setting here, hopefully its clear.

thanks for the help!

Look at the top of the code, things like esp32-blink are highlighted, so the IDE thinks its code.

If your screenshot is the whole code, there is something missing.

The starting comment does not have a start, only the end.

I doubt that the compiler is happy with that.

Hi,
I have recommended to the moderators to move your thread to a more appropriate section.

Can you please post your code, rather than screen captures
To add code please click this link;

Thanks...Tom.. :grinning_face_with_smiling_eyes: :+1: :coffee: :australia:

I'm not 100% sure as i'm not an expert in coding but apart from the comment, can you maybe use #define ledPin 2 or does that not make a difference?

The problem is almost certainly that the code does not start with a /*, but since the OP only posted a picture of part of the code, it's hard to tell.
It is likely that #define wouldn't have worked either.

Hi,
Think we need to know what is going on here first.
Looks like a copy and paste code.

Tom.... :grinning_face_with_smiling_eyes: :+1: :australia:

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