This is the base of my garage door controller, it only got one function in, door() and it will blink a led when http://192.168.1.10/move is called
#include <WiServer.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
#include <WString.h> // include the String library
boolean debug = true;
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,10}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"dd-wrt"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"xxxxxxxxxxxxxxxxxxxxxxxxx"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------
int motorPin = 7; // Pin the motor trigger is connected to
int closePin = 3; //When port is closed
int openPin = 4; //When port is open
void doorMove()
{
digitalWrite(motorPin, LOW);
delay(100);
digitalWrite(motorPin, HIGH);
}
// This is our page serving function that generates web pages
boolean sendMyPage(char* URL)
{
if (strcmp(URL, "/move") == 0)
{
doorMove();
}
WiServer.print(digitalRead(closePin)); WiServer.print("|"); WiServer.print(digitalRead(openPin));
return true;
}
void setup()
{
pinMode(motorPin, OUTPUT); //Set to output to be able to drive the relay
pinMode(closePin, INPUT); //Input from switch telling the motor to stop when port is closed
digitalWrite(closePin, HIGH); //Activate internal pull-up
pinMode(openPin, INPUT); //Input from switch telling the motor to stop when port is open
digitalWrite(openPin, HIGH); //Activate internal pull-up
digitalWrite(motorPin, HIGH); //Set to HIGH when it starts so the TIP102 won't pull the relay.
// Initialize WiServer and have it use the sendMyPage function to serve pages
WiServer.init(sendMyPage);
}
void loop()
{
// Run WiServer
WiServer.server_task();
}