[Subject]
- Adjust brightness of a LED with the PHPoC shield for Arduino

[Hardware Components]
- Arduino Uno
- PHPoC Shield for Arduino
- 220 ohm resistor
Click image for larger version

Name:	LED.jpg
Views:	88
Size:	69.7 KB
ID:	821

[Software Library]
- PHPoC library(WebRemoteSlide)

[Connection Diagram]
Click image for larger version

Name:	LED_fritzing.png
Views:	13
Size:	42.6 KB
ID:	822

[Operation Movie]


[Source Code]
PHP Code:
#include "SPI.h"
#include "Phpoc.h"

// Arduino web server 
PhpocServer server(80);

char slideName;
int slideValue;

void setup() {
  
Serial.begin(9600);
  while(!
Serial)
    ;

  
Phpoc.begin(PF_LOG_SPI PF_LOG_NET);
  
//Phpoc.begin();

  
server.beginWebSocket("remote_slide");

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

  
analogWrite(9100);
}

void loop() {
  
// wait for a new client:
  
PhpocClient client server.available();

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

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

      if(
slideName == 'B')
      {
        
analogWrite(9slideValue 100);
      }

      
Serial.print(slideName);
      
Serial.print('/');
      
Serial.println(slideValue);
    }
  }