• 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

2_1_Web_Server_Outputs how to add more GPIO

Q&A Forum › 2_1_Web_Server_Outputs how to add more GPIO
0 Vote Up Vote Down
Bart Sl asked 1 year ago

Hi,
I like to add more GPIO using example 2_1_Web_Server_Outputs without JS.
How to make it in the simplest way?

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
Duplicate the whole <div class=”card”> div. You’ll have another card with two more buttons.
Give new names to the buttons and assign different URLs. For example:
 

<p>
<a href="on2"><button class="button-on">ON 2</button></a>
<a href="off2"><button class="button-off">OFF 2</button></a>
</p>

 
Then, make sure you add a new placeholder variable for this button, for example:

<p class="state">State: %STATE2%</p>

And add this in the processor function.
 
Additionally, in the ESP32 code, add server.on() functions for those new button URLS:
 

server.on("/on2", HTTP_GET, [](AsyncWebServerRequest *request){
digitalWrite(ledPin2, HIGH);
request->send(SPIFFS, "/index.html", "text/html", false, processor);
});
// Route to set GPIO state to LOW
server.on("/off2", HTTP_GET, [](AsyncWebServerRequest *request){
digitalWrite(ledPin2, LOW);
request->send(SPIFFS, "/index.html", "text/html", false, processor);
});

 
Try these suggestions by yourself and see if you can make it work.
Let me know if you need further help.
 
Regards,
Sara

0 Vote Up Vote Down
Bart Sl answered 1 year ago

Thx Sara,
You are great! Code is working fine!

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Great.
ill mark this issue as resolved.
if you need further help, you just need to open a new question in our forum.
Regards.

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.