Web Server using Arduino Uno + enc28j60

Hello,

Can anybody share an example code/sketch which has the following in it ?

  1. Using ethercard library (enc28j60 chip)
  2. Web page using html ( not java or any other language )
  3. It takes input from user on the web page ( 0 -255 )
  4. changes the PWM output of Arduino pin as per the input received on web page
  5. which easily can be added to my existing program/sketch attached.

Thanks in advance for the help !

New Text Document.txt (4.34 KB)

What made you think that your question has anything to do with the working of this Website and Forum? I have suggested to the Moderator to move it to the Networking section.

This sort of carelessness makes unnecessary work for the Moderators.

It is extremely unlikely that you will find a single example with all your elements - but it is almost certain that there will be examples relevant to each part separately, and many of them will be among the examples that come with the Arduino IDE

Also, please just include the text from your attachment in your Post so people don't have to download the file.

...R

I would like to thank you twice.

Firstly to suggest my question to be shifted to the section you think it should be. Thank you !
Secondly to be so much empathetic for the moderator. Thank you !

One question : Can you pls tell me the purpose of this website & forum ?

Now 1 advice: May I pls request you to be more polite and respectful to others ?

One request : Kindly share few examples which will serve my purpose.

Adherence of your advice:

#include <EtherCard.h>
#define STATIC 1 // DHCP disabled
// MAC Address
static byte mymac = {
0xFA,0x5A,0x51,0x53,0x5A,0x5A };

// ip
static byte myip = {
192,168,1,200 };

static byte subnet = { 255, 255, 255, 0 }; // subnet mask

static byte gwip = { 192,168,1,1 }; //gateway

byte Ethernet::buffer[900];

BufferFiller bfill;
static uint32_t timer;

int LedPins = {
2,3,4,5};

boolean PinStatus = {
1,2,3,4};
const char http_OK PROGMEM =
“HTTP/1.0 200 OK\r\n”
“Content-Type: text/html\r\n”
“Pragma: no-cache\r\n\r\n”;

const char http_Found PROGMEM =
“HTTP/1.0 302 Found\r\n”
“Location: /\r\n\r\n”;

const char http_Unauthorized PROGMEM =
“HTTP/1.0 401 Unauthorized\r\n”
“Content-Type: text/html\r\n\r\n”

401 Unauthorized

”;
void homePage()
{
bfill.emit_p(PSTR("$F"
“ArduinoPIN Webserver”
<font color=“blue”>Home/Office equipment control designed by Vivek Kr Shukla </font size>
"
Air Conditioner put → <a href=”?ArduinoPIN1=$F”>$F</font size>
"
Geyser/Heater put → <a href=”?ArduinoPIN2=$F">$F</font size>
"
Water pump put → <a href=”?ArduinoPIN3=$F">$F</font size>
"
Light put → <a href=”?ArduinoPIN4=$F">$F</font size>"),

http_OK,
PinStatus[1]?PSTR(“off”):PSTR(“on”),
PinStatus[1]?PSTR("<font color=“green”>ON</font size>"):PSTR("<font color=“red”>OFF</font size>"),
PinStatus[2]?PSTR(“off”):PSTR(“on”),
PinStatus[2]?PSTR("<font color=“green”>ON
"):PSTR("<font color=“red”>OFF
"),
PinStatus[3]?PSTR(“off”):PSTR(“on”),
PinStatus[3]?PSTR("<font color=“green”>ON"):PSTR("<font color=“red”>OFF"),
PinStatus[4]?PSTR(“off”):PSTR(“on”),
PinStatus[4]?PSTR("<font color=“green”>ON"):PSTR("<font color=“red”>OFF"));

}
void setup()
{
Serial.begin(9600);
ether.begin(sizeof Ethernet::buffer, mymac, 10);
!ether.staticSetup(myip, gwip);

ether.printIp("My SET IP: ", ether.myip);
ether.printIp("My SET Gateway: ", ether.gwip);

for(int i = 0; i <= 4; i++)
{
pinMode(LedPins*,OUTPUT);*
_ digitalWrite (LedPins*,HIGH);_
_ PinStatus=false;*_

* }*
}
void loop()
{
* delay(1);*
* word len = ether.packetReceive(); // check for ethernet packet*
* word pos = ether.packetLoop(len); // check for tcp packet*
* if (pos) {*
* bfill = ether.tcpOffset();*
_ char data = (char ) Ethernet::buffer + pos;
if (strncmp(“GET /”, data, 5) != 0) {

* bfill.emit_p(http_Unauthorized);*
* }*_

* else {*
* data += 5;*
* if (data[0] == ’ ') { *
* homePage(); // Return home page*
_ for (int i = 0; i <= 3; i++)digitalWrite(LedPins*,!PinStatus[i+1]);
}
// “16” = "?ArduinoPIN1=on “.
else if (strncmp(”?ArduinoPIN1=on “, data, 16) == 0) {
PinStatus[1] = true; _

bfill.emit_p(http_Found);
_ }
else if (strncmp(”?ArduinoPIN2=on “, data, 16) == 0) {
PinStatus[2] = true; _

bfill.emit_p(http_Found);
_ }
else if (strncmp(”?ArduinoPIN3=on “, data, 16) == 0) {
PinStatus[3] = true; _

bfill.emit_p(http_Found);
_ }
else if (strncmp(”?ArduinoPIN4=on ", data, 16) == 0) {
PinStatus[4] = true; _

bfill.emit_p(http_Found);*

* }*
else if (strncmp("?ArduinoPIN1=off ", data, 17) == 0) {
* PinStatus[1] = false; *
* bfill.emit_p(http_Found);
_ }
else if (strncmp("?ArduinoPIN2=off “, data, 17) == 0) {
PinStatus[2] = false; _

bfill.emit_p(http_Found);
_ }
else if (strncmp(”?ArduinoPIN3=off “, data, 17) == 0) {
PinStatus[3] = false; _

bfill.emit_p(http_Found);
_ }
else if (strncmp(”?ArduinoPIN4=off ", data, 17) == 0) {
PinStatus[4] = false; _

bfill.emit_p(http_Found);
_ }
else {
// Page not found*

* bfill.emit_p(http_Unauthorized);*
* }
}
ether.httpServerReply(bfill.position()); // send http response*

* }
}*_

vivekuma047:
One question : Can you pls tell me the purpose of this website & forum ?

There is a difference between "this website and forum" (which probably embraces the whole Arduino Forum) and the "website and forum" section of the Arduino Forum which clearly states that it is for "Improvements for the web system, applications to moderator, spam, etc." and your question was not about that sort of thing.

...R

PS ... To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

Also please use the AutoFormat tool to indent your code consistently for easier reading.