• 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

Book Web Server v2.1 – 2.5 Web Socket – where to add the code for physical buttons

Q&A Forum › Category: ESP32 › Book Web Server v2.1 – 2.5 Web Socket – where to add the code for physical buttons
0 Vote Up Vote Down
ford asked 4 years ago

Hi,  I have been working through your web site and the Book Build Web Servers trying to combine the Websocket tutorial and add physical buttons to this.   The other tutorials on your web page that have buttons are either arduino IDE or non web socket or are so different in their layout that and I just cant seem to figure out where to add this extra code in.  Is there anywhere else that has examples of this or can you point me in the right direction?  Thankyou.

1 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
 
Adding physical buttons is even simpler with WebSocket than with the other methods we have on our website.
 
For example, let’s take a look at example 2.5 and see how we can add that part.
1) Add the code that detects the button presses in the loop.
2) Whenever a button is pressed,  invert the corresponding current output state.
3) Call the notifyClients() function and pass as argument the getOutputStates() function to inform all clients of the new states of your outputs.
 
I hope this helps.
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

  • [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.