Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: Button Webserver - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-10-07 16:32:39 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* generate an arduino sketch for an ESP32-C6 and a */ /* W550 SPI1 connected, which handle a ethernet tcp */ /* socket server in port 3000 */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
//https://github.com/evert-arias/EasyButton #include
//https://github.com/khoih-prog/AsyncWebServer_ESP32_SC_W5500 #include
// Include Ethernet library for ESP32 /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t nose_PushButton_PIN_D4 = 4; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Create an instance of EasyButton for the push button EasyButton button(nose_PushButton_PIN_D4); // Create an instance of AsyncWebServer on port 3000 AsyncWebServer server(3000); /****** FUNCTION PROTOTYPES FOR BUTTON CALLBACKS *****/ void onButtonPressed(void); /****** SETUP FUNCTION *****/ void setup(void) { // Initialize serial communication Serial.begin(115200); // Initialize the button button.begin(); // Attach the callback function to the button press event button.onPressed(onButtonPressed); // Set the push button pin mode pinMode(nose_PushButton_PIN_D4, INPUT_PULLUP); // Start the Ethernet connection ETH.begin(); // Start Ethernet with default settings ETH.config(IPAddress(192, 168, 1, 100), IPAddress(192, 168, 1, 1), IPAddress(255, 255, 255, 0)); // Static IP configuration // Start the server and define the root endpoint server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", "Hello from AsyncWebServer on port 3000!"); }); // Start the server server.begin(); } /****** LOOP FUNCTION *****/ void loop(void) { // Continuously read the button state button.read(); } /****** BUTTON CALLBACK FUNCTION *****/ void onButtonPressed(void) { Serial.println("Button pressed"); } /* END CODE */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)