Erro scope not declared

Olá eu estou tentando descobrir o que está causando o seguinte erro:

E:\TCC\Programação\Contador.sensor.optico\Contador.sensor.optico.ino: In function 'void setup()':
E:\TCC\Programação\Contador.sensor.optico\Contador.sensor.optico.ino:15:3: error: 'motorcSetup' was not declared in this scope
E:\TCC\Programação\Contador.sensor.optico\Contador.sensor.optico.ino:18:3: error: 'motorcAttachPin' was not declared in this scope

exit status 1

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

Estou tentando fazer um controle de velocidade para um motor DC utilizando a saida PWM de um Wemos D1 R32 mas esse erro insiste em me pertubar, se alguem puder me ajudar eu seria muito grato, vc pode ver meu código abaixo:

int pinoLed = 23; //PINO DIGITAL UTILIZADO PELO LED  
int pinoSensor = 19; //PINO DIGITAL UTILIZADO PELO SENSOR
int contador=0;
const int motor = 18;
const int freq = 1000;
const int Channel = 0;
const int resolution = 8;

void setup(){  
  pinMode(pinoSensor, INPUT); //DEFINE O PINO COMO ENTRADA
  pinMode(pinoLed, OUTPUT);  
  digitalWrite(pinoLed, LOW); //LED INICIA DESLIGADO
  Serial.begin(115200);
  // Configuraçao do LED PWM (Passos 1, 2, 3)
  motorcSetup(Channel, freq, resolution);
  
  // Conecte o canal ao GPIO a ser controlado (passo 4)
  motorcAttachPin(motor, Channel);

}  
   
void loop(){
  for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){
    ledcWrite(Channel, dutyCycle);
    delay(20);
  }
  if (digitalRead(pinoSensor) == 1){ //SE A LEITURA DO PINO FOR IGUAL A HIGH, FAZ
        digitalWrite(pinoLed, 1); //ACENDE O LED
        while(digitalRead(pinoSensor)==1){
        contador++; // Ou pode ser count++; que é a mesma coisa
        Serial.print("Vezes que o contador foi ativado => ");
        Serial.println(contador);
        }
  }else{//SENÃO, FAZ
        digitalWrite(pinoLed, 0); //APAGA O LED
        //while(digitalRead(pinoSensor)==0){
        //contador--; // Ou pode ser count++; que é a mesma coisa
        //Serial.print("Vezes que o contador foi ativado => ");
        //Serial.println(contador);
        //delay(50);})
      }
}

OBS: Talvez eu tenha misturado inglês e português escrevendo o código então pode estar confuso

Olá!

motorcSetup() e motorcAttachPin() são duas funções que você está chamando e que não estão definidas em lugar nenhum do seu código.

Se você reaproveitou este código de algum lugar, verifique lá no original se não há a inclusão de alguma biblioteca ou a definição dessas funções que você esqueceu de trazer para o seu.

1 Like

Brazilino - olá será possivel lhe pedir uma ajuda sobre um codigo que estou a tentar passar para o Esp32 e me dá sempre o erro scop....

Olá! Bem vindo ao Fórum.

Posso tentar ajudar, mas se você abrir um novo tópico e contar o que está acontecendo, outras pessoas podem ver também e dar boas dicas também .

eu sou novo aqui ainda nao estou a ver bem como abrir o topico porque é sobre o erro scope

Using library WiFiManager at version 2.0.17 in folder: C:\Users\joaon\Documents\Arduino\libraries\WiFiManager
Using library WiFi at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi
Using library Networking at version 1.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Network
Using library Update at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Update
Using library WebServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WebServer
Using library FS at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\FS
Using library DNSServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\DNSServer
Using library ESP32 Async UDP at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\AsyncUDP
Using library NTPClient at version 3.2.1 in folder: C:\Users\joaon\Documents\Arduino\libraries\NTPClient
Using library TM1637 at version 1.2.0 in folder: C:\Users\joaon\Documents\Arduino\libraries\TM1637
Using library DFRobotDFPlayerMini at version 1.0.6 in folder: C:\Users\joaon\Documents\Arduino\libraries\DFRobotDFPlayerMini
Using library Ai Esp32 Rotary Encoder at version 1.7 in folder: C:\Users\joaon\Documents\Arduino\libraries\Ai_Esp32_Rotary_Encoder
exit status 1

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

Esta parte é no programacao...

isto é um resumo do diz..
estas sao o nome das 2 linhas onde de dá erro... a linha 59 e a linha 61

ledcSetup(0, 5000, 8);
ledcAttachPin(RED_LED, 0);

void setup() {

pinMode(RED_LED, OUTPUT);
pinMode(WHITE_LED, OUTPUT);
// configure LED PWM functionalitites
ledcSetup(0, 5000, 8); 59
// attach the channel to the GPIO to be controlled
ledcAttachPin(RED_LED, 0); 61
red1.setBrightness(Display_backlight);
Serial.begin(9600);
WiFi.begin(ssid, password);

while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}

timeClient.begin();

FPSerial.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

if (!myDFPlayer.begin(FPSerial, /*isACK = */true, /*doReset = */true)) { //Use serial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));

myDFPlayer.volume(20); //Set volume value. From 0 to 30
myDFPlayer.play(1); //Play the first mp3

Serial.println("\n Starting");

rotaryEncoder.begin();
rotaryEncoder.setup(readEncoderISR);
rotaryEncoder.setBoundaries(0, 3500, true); //minValue, maxValue, circleValues true|false (when max go to min and vice versa)
rotaryEncoder.setAcceleration(250);

}

void loop() {

timeClient.update();
red1.showNumberDecEx(timeClient.getHours(),0b01000000,true,2,0);
red1.showNumberDecEx(timeClient.getMinutes(),0b01000000,true,2,2);

Serial.print("Time: ");
Serial.println(timeClient.getFormattedTime());
unsigned long epochTime = timeClient.getEpochTime();
struct tm *ptm = gmtime ((time_t *)&epochTime);
int currentYear = ptm->tm_year+1900;
Serial.print("Year: ");
Serial.println(currentYear);

int monthDay = ptm->tm_mday;
Serial.print("Month day: ");
Serial.println(monthDay);

int currentMonth = ptm->tm_mon+1;
Serial.print("Month: ");
Serial.println(currentMonth);

if (myDFPlayer.available()) {
printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
}

btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);
ledcWrite(0, inc_red_led);
digitalWrite(WHITE_LED, LOW);

//If we detect LOW signal, button is pressed
if (btnState == LOW) {
//if 50ms have passed since last LOW pulse, it means that the
//button has been pressed, released and pressed again
if (millis() - lastButtonPress > 50) {
Serial.println("Button pressed!");
Setup_timer();
}

// Remember last button press event
lastButtonPress = millis();

}

if ( inc_red_led <= 254)
inc_red_led = inc_red_led + 0.1;
else inc_red_led = 0;

delay(1);
if((currentMonth30 + monthDay) >= 121 && (currentMonth30 + monthDay) < 331){
timeClient.setTimeOffset(utcOffsetInSecondsUTC);} // Change daylight saving time - Summer - change 31/03 at 00:00
else {timeClient.setTimeOffset((utcOffsetInSeconds
UTC) - 3600);} // Change daylight saving time - Winter - change 31/10 at 00:00

}

void Setup_timer() {

red1.showNumberDecEx(88,0b01000000,true,2,0);
red1.showNumberDecEx(88,0b01000000,true,2,2);

digitalWrite(RED_LED, HIGH);
digitalWrite(WHITE_LED, HIGH);
myDFPlayer.play(2);
delay(500);

btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);
while (digitalRead(ROTARY_ENCODER_BUTTON_PIN) == HIGH) {

if (rotaryEncoder.encoderChanged())
{
    Serial.println(rotaryEncoder.readEncoder());
    counter = rotaryEncoder.readEncoder();
}
if (rotaryEncoder.isEncoderButtonClicked())
{
    Serial.println("button pressed");
}

minutes = counter / 60;
secondes =  ((counter / 60) - minutes) * 60;
red1.showNumberDecEx(minutes,0b01000000,true,2,0);
red1.showNumberDecEx(secondes,0b01000000,true,2,2);

}
Countdown(counter);
Serial.println("Sortie de la boucle");
}

void Countdown (float timer_counter) {

myDFPlayer.play(8);;
delay(1000);
btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);

while (btnState == HIGH )
{
btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);
for (int i = 10 ; i > 0; i--) {

  timer_counter = timer_counter - 0.1;
  minutes = timer_counter / 60;
  secondes =  ((timer_counter / 60) - minutes) * 60;

red1.showNumberDecEx(minutes,0b01000000,true,2,0);
red1.showNumberDecEx(secondes,0b01000000,true,2,2);
delay(70);
digitalWrite(RED_LED, LOW);
}

if (timer_counter <= 0) {

  myDFPlayer.play(3);

  for ( int i = 0 ; i < 9 ; i++) {
    ledcWrite(0, 255);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, HIGH);
    waitMilliseconds(random(10, 150));
    ledcWrite(0, 0);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, LOW);
    waitMilliseconds(random(10, 150));
  }

  myDFPlayer.play(5);
  
  for ( int i = 0 ; i < 9 ; i++) {
    ledcWrite(0, 255);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, HIGH);
    waitMilliseconds(random(10, 150));
    ledcWrite(0, 0);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, LOW);
    waitMilliseconds(random(10, 150));
  }

  myDFPlayer.play(7);

  for ( int i = 0 ; i < 9 ; i++) {
    ledcWrite(0, 255);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, HIGH);
    waitMilliseconds(random(10, 150));
    ledcWrite(0, 0);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, LOW);
    waitMilliseconds(random(10, 150));
  }

  btnState = LOW;
  counter = 0;
};

}

}

void waitMilliseconds(uint16_t msWait)
{
uint32_t start = millis();

while ((millis() - start) < msWait)
{
// calling mp3.loop() periodically allows for notifications
// to be handled without interrupts
delay(1);
}
}

void printDetail(uint8_t type, int value){
switch (type) {
case TimeOut:
Serial.println(F("Time Out!"));
break;
case WrongStack:
Serial.println(F("Stack Wrong!"));
break;
case DFPlayerCardInserted:
Serial.println(F("Card Inserted!"));
break;
case DFPlayerCardRemoved:
Serial.println(F("Card Removed!"));
break;
case DFPlayerCardOnline:
Serial.println(F("Card Online!"));
break;
case DFPlayerUSBInserted:
Serial.println("USB Inserted!");
break;
case DFPlayerUSBRemoved:
Serial.println("USB Removed!");
break;
case DFPlayerPlayFinished:
Serial.print(F("Number:"));
Serial.print(value);
Serial.println(F(" Play Finished!"));
break;
case DFPlayerError:
Serial.print(F("DFPlayerError:"));
switch (value) {
case Busy:
Serial.println(F("Card not found"));
break;
case Sleeping:
Serial.println(F("Sleeping"));
break;
case SerialWrongStack:
Serial.println(F("Get Wrong Stack"));
break;
case CheckSumNotMatch:
Serial.println(F("Check Sum Not Match"));
break;
case FileIndexOut:
Serial.println(F("File Index Out of Bound"));
break;
case FileMismatch:
Serial.println(F("Cannot Find File"));
break;
case Advertise:
Serial.println(F("In Advertise"));
break;
default:
break;
}
break;
default:
break;
}

}

eu sou novo aqui ainda nao estou a ver bem como abrir o topico porque é sobre o erro scope

Using library WiFiManager at version 2.0.17 in folder: C:\Users\joaon\Documents\Arduino\libraries\WiFiManager
Using library WiFi at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi
Using library Networking at version 1.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Network
Using library Update at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Update
Using library WebServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WebServer
Using library FS at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\FS
Using library DNSServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\DNSServer
Using library ESP32 Async UDP at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\AsyncUDP
Using library NTPClient at version 3.2.1 in folder: C:\Users\joaon\Documents\Arduino\libraries\NTPClient
Using library TM1637 at version 1.2.0 in folder: C:\Users\joaon\Documents\Arduino\libraries\TM1637
Using library DFRobotDFPlayerMini at version 1.0.6 in folder: C:\Users\joaon\Documents\Arduino\libraries\DFRobotDFPlayerMini
Using library Ai Esp32 Rotary Encoder at version 1.7 in folder: C:\Users\joaon\Documents\Arduino\libraries\Ai_Esp32_Rotary_Encoder
exit status 1

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

Esta parte é no programacao...

isto é um resumo do diz..
estas sao o nome das 2 linhas onde de dá erro... a linha 59 e a linha 61

ledcSetup(0, 5000, 8);
ledcAttachPin(RED_LED, 0);

void setup() {

pinMode(RED_LED, OUTPUT);
pinMode(WHITE_LED, OUTPUT);
// configure LED PWM functionalitites
ledcSetup(0, 5000, 8); 59
// attach the channel to the GPIO to be controlled
ledcAttachPin(RED_LED, 0); 61
red1.setBrightness(Display_backlight);
Serial.begin(9600);
WiFi.begin(ssid, password);

while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}

timeClient.begin();

FPSerial.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

if (!myDFPlayer.begin(FPSerial, /*isACK = */true, /*doReset = */true)) { //Use serial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));

myDFPlayer.volume(20); //Set volume value. From 0 to 30
myDFPlayer.play(1); //Play the first mp3

Serial.println("\n Starting");

rotaryEncoder.begin();
rotaryEncoder.setup(readEncoderISR);
rotaryEncoder.setBoundaries(0, 3500, true); //minValue, maxValue, circleValues true|false (when max go to min and vice versa)
rotaryEncoder.setAcceleration(250);

}

void loop() {

timeClient.update();
red1.showNumberDecEx(timeClient.getHours(),0b01000000,true,2,0);
red1.showNumberDecEx(timeClient.getMinutes(),0b01000000,true,2,2);

Serial.print("Time: ");
Serial.println(timeClient.getFormattedTime());
unsigned long epochTime = timeClient.getEpochTime();
struct tm *ptm = gmtime ((time_t *)&epochTime);
int currentYear = ptm->tm_year+1900;
Serial.print("Year: ");
Serial.println(currentYear);

int monthDay = ptm->tm_mday;
Serial.print("Month day: ");
Serial.println(monthDay);

int currentMonth = ptm->tm_mon+1;
Serial.print("Month: ");
Serial.println(currentMonth);

if (myDFPlayer.available()) {
printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
}

btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);
ledcWrite(0, inc_red_led);
digitalWrite(WHITE_LED, LOW);

//If we detect LOW signal, button is pressed
if (btnState == LOW) {
//if 50ms have passed since last LOW pulse, it means that the
//button has been pressed, released and pressed again
if (millis() - lastButtonPress > 50) {
Serial.println("Button pressed!");
Setup_timer();
}

// Remember last button press event
lastButtonPress = millis();

}

if ( inc_red_led <= 254)
inc_red_led = inc_red_led + 0.1;
else inc_red_led = 0;

delay(1);
if((currentMonth30 + monthDay) >= 121 && (currentMonth30 + monthDay) < 331){
timeClient.setTimeOffset(utcOffsetInSecondsUTC);} // Change daylight saving time - Summer - change 31/03 at 00:00
else {timeClient.setTimeOffset((utcOffsetInSeconds
UTC) - 3600);} // Change daylight saving time - Winter - change 31/10 at 00:00

}

void Setup_timer() {

red1.showNumberDecEx(88,0b01000000,true,2,0);
red1.showNumberDecEx(88,0b01000000,true,2,2);

digitalWrite(RED_LED, HIGH);
digitalWrite(WHITE_LED, HIGH);
myDFPlayer.play(2);
delay(500);

btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);
while (digitalRead(ROTARY_ENCODER_BUTTON_PIN) == HIGH) {

if (rotaryEncoder.encoderChanged())
{
    Serial.println(rotaryEncoder.readEncoder());
    counter = rotaryEncoder.readEncoder();
}
if (rotaryEncoder.isEncoderButtonClicked())
{
    Serial.println("button pressed");
}

minutes = counter / 60;
secondes =  ((counter / 60) - minutes) * 60;
red1.showNumberDecEx(minutes,0b01000000,true,2,0);
red1.showNumberDecEx(secondes,0b01000000,true,2,2);

}
Countdown(counter);
Serial.println("Sortie de la boucle");
}

void Countdown (float timer_counter) {

myDFPlayer.play(8);;
delay(1000);
btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);

while (btnState == HIGH )
{
btnState = digitalRead(ROTARY_ENCODER_BUTTON_PIN);
for (int i = 10 ; i > 0; i--) {

  timer_counter = timer_counter - 0.1;
  minutes = timer_counter / 60;
  secondes =  ((timer_counter / 60) - minutes) * 60;

red1.showNumberDecEx(minutes,0b01000000,true,2,0);
red1.showNumberDecEx(secondes,0b01000000,true,2,2);
delay(70);
digitalWrite(RED_LED, LOW);
}

if (timer_counter <= 0) {

  myDFPlayer.play(3);

  for ( int i = 0 ; i < 9 ; i++) {
    ledcWrite(0, 255);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, HIGH);
    waitMilliseconds(random(10, 150));
    ledcWrite(0, 0);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, LOW);
    waitMilliseconds(random(10, 150));
  }

  myDFPlayer.play(5);
  
  for ( int i = 0 ; i < 9 ; i++) {
    ledcWrite(0, 255);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, HIGH);
    waitMilliseconds(random(10, 150));
    ledcWrite(0, 0);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, LOW);
    waitMilliseconds(random(10, 150));
  }

  myDFPlayer.play(7);

  for ( int i = 0 ; i < 9 ; i++) {
    ledcWrite(0, 255);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, HIGH);
    waitMilliseconds(random(10, 150));
    ledcWrite(0, 0);
    waitMilliseconds(random(10, 150));
    digitalWrite(WHITE_LED, LOW);
    waitMilliseconds(random(10, 150));
  }

  btnState = LOW;
  counter = 0;
};

}

}

void waitMilliseconds(uint16_t msWait)
{
uint32_t start = millis();

while ((millis() - start) < msWait)
{
// calling mp3.loop() periodically allows for notifications
// to be handled without interrupts
delay(1);
}
}

void printDetail(uint8_t type, int value){
switch (type) {
case TimeOut:
Serial.println(F("Time Out!"));
break;
case WrongStack:
Serial.println(F("Stack Wrong!"));
break;
case DFPlayerCardInserted:
Serial.println(F("Card Inserted!"));
break;
case DFPlayerCardRemoved:
Serial.println(F("Card Removed!"));
break;
case DFPlayerCardOnline:
Serial.println(F("Card Online!"));
break;
case DFPlayerUSBInserted:
Serial.println("USB Inserted!");
break;
case DFPlayerUSBRemoved:
Serial.println("USB Removed!");
break;
case DFPlayerPlayFinished:
Serial.print(F("Number:"));
Serial.print(value);
Serial.println(F(" Play Finished!"));
break;
case DFPlayerError:
Serial.print(F("DFPlayerError:"));
switch (value) {
case Busy:
Serial.println(F("Card not found"));
break;
case Sleeping:
Serial.println(F("Sleeping"));
break;
case SerialWrongStack:
Serial.println(F("Get Wrong Stack"));
break;
case CheckSumNotMatch:
Serial.println(F("Check Sum Not Match"));
break;
case FileIndexOut:
Serial.println(F("File Index Out of Bound"));
break;
case FileMismatch:
Serial.println(F("Cannot Find File"));
break;
case Advertise:
Serial.println(F("In Advertise"));
break;
default:
break;
}
break;
default:
break;
}

}

No caso da área em língua Portuguesa do Fórum nós não temos subtemas, então quando você quiser abrir um tópico é suficiente que você acesse o Fórum em

https://forum.arduino.cc/c/international/portugues/

e clique aqui:

Aproveitando a oportunidade, sempre insistimos para que as pessoas leiam o tópico
Como Obter o Melhor desse Fórum antes de postar, porque ele contém dicas importantes sobre as postagens.

Ao contrário do caso anterior, que gerou este tópico, ledcSetup() era uma função que já vinha inclusa na biblioteca padrão para os ESP32. Porém, essa biblioteca foi atualizada recentemente e essa função não é mais utilizada.

Veja aqui --> https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html#ledc

Você vai precisar adaptar seu programa utilizando a função ledcAttach() no formato abaixo:

ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution);

1 Like

nas duas linhas que diz ..

ledcSetup(0, 5000, 8);
ledcAttachPin(RED_LED, 0);

desculpa mas não estou a perceber..

O que estou a dizer é que as funções ledcSetup() e ledcAttachPin() foram removidas nas versões mais novas da plataforma das placas ESP32. Assim, o programa que você tinha feito e talvez funcionasse no passado não funciona mais. Ele chama funções que não existem.
Você terá que reescrever essa parte do seu programa substituindo as funções acima por ledcAttach(), no formato que eu citei no post #7 .

1 Like

mas a minha pergunta é.. na linhas de...
ledcSetup(0, 5000, 8);
ledcAttachPin(RED_LED, 0);

tenho de escrever o que me indicou no Post#7

desculpa estar a perguntar mas eu tenho de perceber o que faço...

mas a minha pergunta é.. na linhas de...
ledcSetup(0, 5000, 8);
ledcAttachPin(RED_LED, 0);

tenho de escrever o que me indicou no Post#7

desculpa estar a perguntar mas eu tenho de perceber o que faço...

Isso, apague essas linhas e coloque essa no lugar:

ledcAttach(RED_LED,5000,8);
1 Like

olá já passei a linha para a esp32 e não deu nenhum erro agora vou montar o kit e ver se funciona. ok

Noutro projeto também tenho um problema dá um erro falta de espaço na esp.
aqui vai a amostra...

Using library AnimatedGIF at version 2.1.0 in folder: C:\Users\joaon\Documents\Arduino\libraries\AnimatedGIF
Using library WiFiManager at version 2.0.17 in folder: C:\Users\joaon\Documents\Arduino\libraries\WiFiManager
Using library WiFi at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi
Using library Networking at version 1.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Network
Using library Update at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Update
Using library WebServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WebServer
Using library FS at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\FS
Using library DNSServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\DNSServer
Using library ESP32 Async UDP at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\AsyncUDP
Using library NTPClient at version 3.2.1 in folder: C:\Users\joaon\Documents\Arduino\libraries\NTPClient
Using library DFRobotDFPlayerMini at version 1.0.6 in folder: C:\Users\joaon\Documents\Arduino\libraries\DFRobotDFPlayerMini
Using library SPI at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\SPI
Using library TFT_eSPI at version 2.5.43 in folder: C:\Users\joaon\Documents\Arduino\libraries\TFT_eSPI
Using library SPIFFS at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\SPIFFS
Using library Adafruit SHT31 Library at version 2.2.2 in folder: C:\Users\joaon\Documents\Arduino\libraries\Adafruit_SHT31_Library
Using library Adafruit BusIO at version 1.16.1 in folder: C:\Users\joaon\Documents\Arduino\libraries\Adafruit_BusIO
Using library Wire at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Wire
"C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\tools\esp-x32\2302/bin/xtensa-esp32-elf-size" -A "C:\Users\joaon\AppData\Local\Temp\arduino\sketches\9C920E853756FC5C80C5D39A2B9F33F1/Fallout_PipBoy3000_Celsius.ino.elf"
Sketch uses 1368801 bytes (104%) of program storage space. Maximum is 1310720 bytes.
Global variables use 68456 bytes (20%) of dynamic memory, leaving 259224 bytes for local variables. Maximum is 327680 bytes.
Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it.
text section exceeds available space in board

Compilation error: text section exceeds available space in board

olá já passei a linha para a esp32 e não deu nenhum erro agora vou montar o kit e ver se funciona. ok

Noutro projeto também tenho um problema dá um erro falta de espaço na esp.
aqui vai a amostra...

Using library AnimatedGIF at version 2.1.0 in folder: C:\Users\joaon\Documents\Arduino\libraries\AnimatedGIF
Using library WiFiManager at version 2.0.17 in folder: C:\Users\joaon\Documents\Arduino\libraries\WiFiManager
Using library WiFi at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi
Using library Networking at version 1.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Network
Using library Update at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Update
Using library WebServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\WebServer
Using library FS at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\FS
Using library DNSServer at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\DNSServer
Using library ESP32 Async UDP at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\AsyncUDP
Using library NTPClient at version 3.2.1 in folder: C:\Users\joaon\Documents\Arduino\libraries\NTPClient
Using library DFRobotDFPlayerMini at version 1.0.6 in folder: C:\Users\joaon\Documents\Arduino\libraries\DFRobotDFPlayerMini
Using library SPI at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\SPI
Using library TFT_eSPI at version 2.5.43 in folder: C:\Users\joaon\Documents\Arduino\libraries\TFT_eSPI
Using library SPIFFS at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\SPIFFS
Using library Adafruit SHT31 Library at version 2.2.2 in folder: C:\Users\joaon\Documents\Arduino\libraries\Adafruit_SHT31_Library
Using library Adafruit BusIO at version 1.16.1 in folder: C:\Users\joaon\Documents\Arduino\libraries\Adafruit_BusIO
Using library Wire at version 2.0.0 in folder: C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\libraries\Wire
"C:\Users\joaon\AppData\Local\Arduino15\packages\esp32\tools\esp-x32\2302/bin/xtensa-esp32-elf-size" -A "C:\Users\joaon\AppData\Local\Temp\arduino\sketches\9C920E853756FC5C80C5D39A2B9F33F1/Fallout_PipBoy3000_Celsius.ino.elf"
Sketch uses 1368801 bytes (104%) of program storage space. Maximum is 1310720 bytes.
Global variables use 68456 bytes (20%) of dynamic memory, leaving 259224 bytes for local variables. Maximum is 327680 bytes.
Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it.
text section exceeds available space in board

Compilation error: text section exceeds available space in board

Está claro que seu programa é grande demais para a memória da placa. Avalie se você precisa mesmo de todas as bibliotecas que está usando. Se tudo for absolutamente necessário, talvez alterar o sistema de partição do ESP para programas grandes resolva.

Eu volto a insistir para que você leia o tópico Como Obter o Melhor desse Fórum. Você escreveu sua primeira dúvida no post de outra pessoa, o que é contra as normas do Forum e agora está fazendo isso uma segunda vez... :upside_down_face: