• 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

Referance: ESP32 Web Server – Control Outputs

Q&A Forum › Category: Other › Referance: ESP32 Web Server – Control Outputs
0 Vote Up Vote Down
senake sandanayake asked 7 years ago

I refer the code given for the above practical. I want to keep one of the LEDs to be on for 10 seconds and goes off automatically while the other one works as it is. How can I achieve this by changing the code given? Can some one help me. 

Question Tags: ESP32 Question from senake
3 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

Hi Senake, the best way of doing that is to create a timer that starts when you press a button that after checks the amount of time that has passed and automatically turns of the LED after those 10 seconds.
Tomorrow or Wednesday I’ll be posting a new Unit in the Learn ESP32 Course dedicated to create timers with the ESP32, I think after you use that Unit you should be able to modify the web server sketch with the timer. 
I’ll let you know when the new Unit is posted.
Thanks!

0 Vote Up Vote Down
senake sandanayake answered 7 years ago

Thanks Rui

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

I’ve just published the Unit that I was talking about: ESP32 with PIR Motion Sensor – Interrupts and Timers
Take a look at the example with the PIR Motion sensor, but basically you want to modify that code to use in your web server sketch. You’ll need to have a startTimer boolean variable that is set to true when you press a button in the web server that will start the timer to turn off the output after X number of seconds.
I hope that helps.
Regards,
Rui

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

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition 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.