[Project]
Web-based Servo Control with PHPoC Shield for Arduino

[Product]
* Arduino Uno Rev.3
* PHPoC Shield for Arduino

[Sensor/Module]
* Tower Pro Servo Motor: SG92R

[Connection]
* SG92R (Red) --- (5V) Shield
* SG92R (Orange) --- (~9) Shield
* SG92R (Brown) --- (GND) Shield

[How it works]
a. Connect PHPoC Shield for Arduino on your Arduino
b. Connect USB wireless LAN dongle to the shield for using Wireless LAN
c. Access to the shield's web page and control your servo in "Web Remote Control / Slide" application.

[video]



[Source Code]

PHP Code:
#include "SPI.h"
#include "Phpoc.h"
#include "Servo.h"

PhpocServer server(80);
Servo myservo;
char slideName;
int slideValue;

void setup() {

  
myservo.attach(9);

  
Serial.begin(115200);
  while(!
Serial)
    ;

  
Phpoc.begin(PF_LOG_SPI PF_LOG_NET);
  
server.beginWebSocket("remote_slide");

  
Serial.print("WebSocket server address : ");
  
Serial.println(Phpoc.localIP());  
}

void loop() {
  
PhpocClient client server.available();

  if (
client) {
    
String slideStr client.readLine();

    if(
slideStr) {
      
slideName slideStr.charAt(0);
      
slideValue slideStr.substring(1).toInt();

      if(
slideName == 'A'){
        
int pos map(slideValue, -1001000180);
        
myservo.write(pos);
        
Serial.println(pos);
      }
    }
  }