• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Compilation error: 'ledcSetup' was not declared in this scope

Q&A Forum › Category: ESP32 › Compilation error: 'ledcSetup' was not declared in this scope
0 Vote Up Vote Down
James Baxter asked 10 months ago

Getting same message for val = hallRead()

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 10 months ago

Hi.
There was an update on the ESP32 core for Arduino IDE and there were some breaking changes.
The hallRead() function no longer exists, so that feature is no longer supported.
The ledcSetup function is also no longer supported.

If you update to version 3.0, there are a few changes required to make the code compile. We’ll update the eBook in the upcoming weeks.
Here are the required changes for PWM:

#define LED_PIN 2
// setting PWM properties
const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;

Previously for version 2 ESP32 board add-on inside the setup function:

// configure LED PWM functionalities
ledcSetup(ledChannel, freq, resolution);
// attach the channel to the GPIO to be controlled
ledcAttachPin(LED_PIN, ledChannel);
ledcWrite(ledChannel, 0);

For the NEW version 3 ESP32 board add-on inside the setup function:

ledcAttachChannel(LED_PIN , freq, resolution, ledChannel);
ledcWrite(LED_PIN, 0);

Let me know if you can make it work. Otherwise, I can try to send you the correct code.

Regards,
Sara

0 Vote Up Vote Down
James Baxter answered 10 months ago

Fantastic response time! thank you.

0 Vote Up Vote Down
Sara Santos Staff answered 10 months ago

We already updated the code to be compatible with the newest version.
You can find it here: https://github.com/RuiSantosdotme/ESP32-Course/blob/master/code/LED_PWM_Example_1/LED_PWM_Example_1.ino
 
We’re currently working on updating the eBook PDF. 
All codes are updated now. We’ve just finished updating this morning. All links already redirect to the most recent code.
 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.