Arduino MEGA Ethernet Web Server for Controlling 24 Outputs

In this tutorial, an Arduino MEGA 2560 and Ethernet shield are used to make a web server that hosts a web page that allows 24 outputs to be controlled using checkboxes. The tutorial on the Arduino MEGA web server contains the circuit diagram and all of the source code for the project.




This tutorial was written to answer a question on the blog about the Arduino web server tutorial.

An image of the web server with the web page used to control 24 LEDs is shown below.

24 Output Arduino MEGA Web Server using the Ethernet Shield

24 Output Arduino MEGA Web Server using the Ethernet Shield

7 thoughts on “Arduino MEGA Ethernet Web Server for Controlling 24 Outputs

  1. Hi,
    How can I switch a LED state with a physical button too?

    Thank you for this great sketch and “Ethernet Shield Web Server”. You deserve my donation.

  2. Hi again,
    with the original sketch it’s easy to create cases like “if LED 5 ON, will switch OFF LED 6”
    … but on new sketch I can’t do this.

    • You really need to understand exactly how the code works in order to modify it.

      I want to look at making a general purpose template or similar design that makes development easier – when I get the time.

  3. This website is a gold mine for me. I am new to programming and need a push to keep me going. I am trying to understand what I am doing, but this has stopped me.

    I am trying to modify this to include light and motion sensors. I get this msg while compiling :
    Arduino: 1.6.12 (Windows 10), Board: “Arduino/Genuino Uno”

    C:\Users\Patrick\Documents\Arduino\eth_websrv_SD_Ajax_24_outZ-pir-ldr\eth_websrv_SD_Ajax_24_outZ-pir-ldr.ino: In function ‘void loop()’:

    eth_websrv_SD_Ajax_24_outZ-pir-ldr:150: error: ‘StrContains’ was not declared in this scope

    if (StrContains(HTTP_req, “ajax_inputs”)) {

    ^

    eth_websrv_SD_Ajax_24_outZ-pir-ldr:155: error: ‘SetLEDs’ was not declared in this scope

    SetLEDs();

    ^

    eth_websrv_SD_Ajax_24_outZ-pir-ldr:157: error: ‘XML_response’ was not declared in this scope

    XML_response(client);

    ^

    eth_websrv_SD_Ajax_24_outZ-pir-ldr:177: error: ‘StrClear’ was not declared in this scope

    StrClear(HTTP_req, REQ_BUF_SZ);

    ^

    C:\Users\Patrick\Documents\Arduino\eth_websrv_SD_Ajax_24_outZ-pir-ldr\eth_websrv_SD_Ajax_24_outZ-pir-ldr.ino: At global scope:

    eth_websrv_SD_Ajax_24_outZ-pir-ldr:256: error: expected declaration before ‘}’ token

    }

    ^

    Multiple libraries were found for “SPI.h”
    Used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
    Not used: C:\Users\Patrick\Documents\Arduino\libraries\SPI
    Multiple libraries were found for “Ethernet.h”
    Used: C:\Users\Patrick\Documents\Arduino\libraries\Ethernet
    Not used: C:\Program Files (x86)\Arduino\libraries\Ethernet
    Multiple libraries were found for “SD.h”
    Used: C:\Users\Patrick\Documents\Arduino\libraries\SD
    Not used: C:\Program Files (x86)\Arduino\libraries\SD
    exit status 1
    ‘StrContains’ was not declared in this scope

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    Can you tell me how to fix this? Is it a #define statement?

Leave a Reply

Your email address will not be published. Required fields are marked *