Arduino Web UI

Hey Everyone. I am new to both Arduino and the forum but hoped that someone maybe able to offer some advice.

I’ve created a system that uses the Uno R3, Wifi Shield and various timed linear actuators to open / close a box following a trigger . Everything works great but I really want a nice web or iphone app to trigger the actions and eventually display additional sensor values.

I’ve looked at loads of options including Dweet and freeboard but this doesnt seemt o allow event triggering and monitoring.

If anyone has any advice it would be greatly appreciated.

Thanks

James

#include <SPI.h>
#include <WiFi.h>

const int WarningL = 9; //relay for warning system
const int WarningS = 8;
//Pin 10 is by WIFI for SS
const int DoorIn = 6; // relay 1 for linear actuator 1 - action retract (close doors)
const int DoorOut = 5; //relay 2 for linear actuator 1 - action extend (open doors)
//Pin 7 using by Wifi for handshake
const int PlatformUp = 3; // relay 1 for linear actuator 2 - action retract (lower platform)
const int PlatformDown= 2; // relay 2 for linear actuator 2 - action extend (raise platform)
//Pin 4 used by WIFI for SD

char ssid = “YB_WiFi”; // network SSID (name)
char pass = “*******”; // network password
int keyIndex = 0; // network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
WiFiServer server(80);

void setup() {
pinMode(WarningL, OUTPUT);
pinMode(WarningS, OUTPUT);
pinMode(DoorIn, OUTPUT);
pinMode(DoorOut, OUTPUT);
pinMode(PlatformUp, OUTPUT);
pinMode(PlatformDown, OUTPUT);

Serial.begin(9600); // initialize serial communication

// check for presence of the wifishield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println(“WiFi shield not found”);
while (true); // don’t continue
}

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
server.begin(); // start the web server on port 80
printWifiStatus(); // now connected, so print out the status
}

void loop() {
WiFiClient client = server.available(); // listen for incoming clients

if (client) { // if you get a client,
Serial.println(“new client”); // print a message out the serial port
String currentLine = “”; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client’s connected
if (client.available()) { // if there’s bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == ‘\n’) { // if the byte is a newline character

// if the current line is blank, you got two newline characters in a row.
// that’s the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what’s coming, then a blank line:
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-type:text/html”);
client.println();

// the content of the HTTP response follows the header:
client.print(“Click <a href=”/H">here to Close OrbitalOne
“);
client.print(“Click <a href=”/L”>here to Open OrbitalOne
");

// The HTTP response ends with another blank line:
client.println();
// break out of the while loop:
break;
}
else { // if you got a newline, then clear currentLine:
currentLine = “”;
}
}
else if (c != ‘\r’) { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}

// Check to see if the client request was “/H” or “/L”:
if (currentLine.endsWith("/H")) {
digitalWrite(WarningL, HIGH); // turn the warning system (HIGH is the voltage level)
digitalWrite(WarningS,HIGH);
delay(5000); // wait for 5 seconds
digitalWrite(DoorOut, HIGH); // extend the linear actuators for the top doors = box opens
delay(10000); // extend for 10second (timing needs to be confirmed)
digitalWrite(DoorOut,LOW); // linear actuator stops after timed opening (add a microswitch to confirm?)
delay(100); // delay
digitalWrite(PlatformUp,HIGH); // Extend secondary linear (LA2) - platform raises
delay(10000); // Extend for 20second (timing needs to be confirmed)
digitalWrite(PlatformUp, LOW); // stop linear actuator
delay(5000); // delay prior to warning system shutdown
digitalWrite(WarningL, LOW); // Warning System Shutdown
digitalWrite(WarningS, LOW);
delay(2000);
}
if (currentLine.endsWith("/L")) {
digitalWrite(WarningL, LOW); // The following items are the reverse of the process outlined above
digitalWrite(WarningS, LOW);
delay(5000);
digitalWrite(PlatformDown, HIGH);
delay(10000);
digitalWrite(PlatformDown,LOW);
delay(100);
digitalWrite(DoorIn,HIGH);
delay(10000);
digitalWrite(DoorIn, LOW);
delay(1000);
digitalWrite(WarningL, LOW);
digitalWrite(WarningS, LOW);
delay(1000);
}
}
}
// close the connection:
client.stop();
Serial.println(“client disonnected”);
}
}

void printWifiStatus() {
// print the SSID of the network you’re attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// print your WiFi shield’s IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print(“signal strength (RSSI):”);
Serial.print(rssi);
Serial.println(" dBm");
// print where to go in a browser:
Serial.print(“To see this page in action, open a browser to http://”);
Serial.println(ip);
}