Use the code below with Fred's Web Server code. (http://forums.netdui...ted-web-server/)
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.IO;
using Ethernet.Data;
namespace NetduinoPlusWebServer
{
public class Program
{
static AnalogInput photcell;
public static void Main()
{
Listener webServer = new Listener(RequestReceived);
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
photcell = new AnalogInput(Pins.GPIO_PIN_A5);
photcell.SetRange(0, 255);
while (true)
{
// Blink LED to show we're still responsive
led.Write(!led.Read());
Thread.Sleep(500);
}
}
private static void RequestReceived(Request request)
{
int shade = photcell.Read();
request.SendResponse(
"<html>" +
"<header> <meta http-equiv=\"refresh\" content=\"2\"></header>" +
"<body style=\"background-color: rgb(" + shade + "," + shade + "," + shade + ")\">" +
"<p> Time (relative to start time): " + DateTime.Now.ToString() + "</p>" +
"<p> Value: " + shade + "</p>" +
"</body>" +
"</html>"
);
}
}
}
Thanks a bunch for the web server code Fred!