Hello,
I have been using the progmem web-server example found at:http://arduino.cc/playground/Code/WebServer. Out of the two examples shown, the one I am referencing is the first one, higher up on the page than the other. All that is needed to get the example server working is change the IP address to an unused one one your network(in my case 192.168.1.230), plug the Arduino uno into your router, and upload the code.
Libraries it is using:
#include <SPI.h>
#include <Ethernet.h>
#include <avr/pgmspace.h>
#include <string.h>
This example web-server displays a title webpage with links across the top to other pages. What I am trying to do seems simple, but I haven't been able to find a way, both through searching and forum scouring.
What I want to do:
On the first http page, shown in the code as "Page 1", There is a bit of text that says "Nothing... yet.".
I am trying to change that text "Nothing... yet." to either "On" or "Off" based on the reading from an analogread command in a function that I am adding lower in the code.
But, because the text ""Nothing... yet." is inside of an array (or array pointer), I cant change it.
I have looked into changing elements in arrays, but this web-server example uses arrays in a way that I can't locate which place(or element) in the array it is, to change the text.
This is the idea of how I want to change it:
Example code(unchanged):
PROGMEM prog_char content_page1[] = "<hr /><h3>Content of Page 1</h3><p>Nothing... yet.</p>
<form action=\"/login\" method=\"POST\"><input type=\"text\" name=\"prova\"><input type=\"submit\" value=\"post\"></form>";
Example code(with my code):
PROGMEM prog_char content_page1[] = "<hr /><h3>Content of Page 1</h3><p>onOrOff();</p>
<form action=\"/login\" method=\"POST\"><input type=\"text\" name=\"prova\"><input type=\"submit\" value=\"post\"></form>";
///////Further Down in the Code/////////
void PROGMEM onOrOff() {
if(analogRead(5)<500) //965 = on, 0 = off
{
return "On";
}
else
{
return "Off";
}
}
This is the idea that I have to change it, not the code that must be used. I know this code wouldn't work anyways.
I have tried numerous ways to try and change that text, but no success.
I have even added code that printed every single char from a certain array(that I chose) out to serial when ever I would hit a certain button, and even with that, I couldn't find the http data chars "Nothing... yet.". I didn't try EVERY single array tho.
I take any help, ideas, examples, etc.
I really have no preference on the method, I can alter it after I get it working.
I am stuck.