Update: 2024-03-10

Esp32 OnBoardLed als Arduino Tab.

OnBoardLed.ino

// ****************************************************************
// Arduino IDE Tab Esp32 OnBoardLed Modular
// created: Jens Fleischer, 2018-09-21
// last mod: Jens Fleischer, 2020-04-06
// For more information visit: https://fipsok.de
// ****************************************************************
// Hardware: Esp32
// Software: Esp32 Arduino Core 1.0.0 - 2.0.14
// Getestet auf: ESP32 NodeMCU-32s
/******************************************************************
  Copyright (c) 2018 Jens Fleischer. All rights reserved.

  This file is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This file is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
*******************************************************************/
// Diese Version von OnBoardLed sollte als Tab eingebunden werden.
// #include <ESP8266WebServer.h> muss im Haupttab aufgerufen werden
// Die Funktionalität des ESP8266 Webservers ist erforderlich.
// Die Funktion "onboardLed();" muss im Setup aufgerufen werden.
/**************************************************************************************/

void onboardLed() {
  pinMode(LED_BUILTIN, OUTPUT);     // OnBoardLed Esp32
  server.on("/bled", []() {
    if (server.hasArg("zap")) {
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));    // LED umschalten
      DEBUG_P(digitalRead(LED_BUILTIN) ? "LED ist an" : "LED ist aus");
    }
    server.send(200, "text/plain", digitalRead(LED_BUILTIN) ? "Aus" : "Ein");
  });
}

Die Webseite zum Esp32 OnBoardLed Tab.

onboardled.html

<!DOCTYPE html> <!-- For more information visit: https://fipsok.de -->
<html lang="de">
   <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link rel="stylesheet" href="style32.css">
      <title>Onboard Led</title>
   </head>
   <body>
      <h2>Onboard Led schalten</h2>
      <h2>ESP32 Dev Module</h2>
      <button class="button"></button>
      <script>
         function once(arg) {
           fetch('bled' + arg).then(function (response) {
             return response.text();
           }).then(function (text) {
             elem.innerHTML = 'LED ' + text;
             text == 'Ein' ? elem.style.backgroundColor = '#adff2f' : elem.style.backgroundColor = 'red';
           });
         }
         var elem = document.querySelector('button');
         elem.addEventListener('click', function () {
           once('?zap=');
         });
         once('');
      </script>
   </body>
</html>