Web Controlled Arduino LED

details

This instructable shows you how to build a Web-enabled tri-color LED based on an Arduino and the WIZnet Ethernet shield, controllable from any Web browser .

 

Check the live demo at http://try.yaler.net/~arduino/led

Because the LED is exposed through a simple RESTful web service running on the Arduino color changes can also be triggered by Pachube or other platforms offering Web hooks. Welcome to the Web of Things ! The LED can of course be replaced by a motor or a high voltage switching relay to enable more interesting browser controlled applications, e.g. for home automation.

 

Material

  • Arduino Duemilanove ATmega 328
  • Arduino WIZnet Ethernet Shield
  • Tri color LED

Infrastructure

  • Internet access with DHCP, no public IP address needed for Arduino
  • (Optional: PC or Cloud Server with a public IP address, to run Yaler)

 

LED Test

FBD0UFIG5FQZWRL.MEDIUM

// HelloLed.pde

int redPin = 6;
int greenPin = 5;
int bluePin = 3;

void setColor (int red, int green, int blue) {
  // SparkFun LED: write value for each color
  //analogWrite(redPin, red);
  //analogWrite(greenPin, green);
  //analogWrite(bluePin, blue);

  // Ladyada LED: write inverted value for each color
  analogWrite(redPin, 255 - red);
  analogWrite(greenPin, 255 - green);
  analogWrite(bluePin, 255 - blue);

  delay(1000);
}

void setup () {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop () {
  setColor(0, 0, 0); // Off
  setColor(255, 0, 0); // Red
  setColor(0, 255, 0); // Green
  setColor(0, 0, 255); // Blue
  setColor(0, 255, 255); // Aqua
  setColor(255, 255, 0); // Yellow
  setColor(255, 0, 255); // Fuchsia
  setColor(255, 255, 255); // White
}

 

Accessing and controlling the Arduino from the Web

FHVYO1IGC4G0PNR.MEDIUM

If everything works as intended, you should see a simple HTML page with three colored buttons . If you press a button, the Arduino LED should light up in the corresponding color.

Behind the scenes this works with a simple Javascript that sends an HTTP PUT request , e.g. PUT http://try.yaler.net/gsiot-ffmq-ttd5/led/ff0000 to the Arduino to set the LED’s color. You can use Firefox with the Firebug add-on set to Net > XHR to see the PUT requests.

Note that the URL does not depend on the current location of the Arduino. No matter if it’s attached to your home network or to the LAN at your office, the URL remains the same. Just plug in the Arduino and control it with your browser.

Because typing the URL can be cumbersome, you can make use of a QR-Code generator like http://qrcode.kaywa.com/ to get a QR-Code of your Arduino’s URL (example below).

Print it, stick it to your Arduino, access it with a QR-Code reader like Lynkee(iPhone), Kaywa (Symbian, Java phones) or Quickmark (Windows Mobile) and there you have a switch-less, yet conveniently controllable Arduino.

Source : http://www.instructables.com/id/Arduino-Web-LED/

This instructable shows you how to build a Web-enabled tri-color LED based on an Arduino and the WIZnet Ethernet shield, controllable from any Web browser .

 

Check the live demo at http://try.yaler.net/~arduino/led

Because the LED is exposed through a simple RESTful web service running on the Arduino color changes can also be triggered by Pachube or other platforms offering Web hooks. Welcome to the Web of Things ! The LED can of course be replaced by a motor or a high voltage switching relay to enable more interesting browser controlled applications, e.g. for home automation.

 

Material

  • Arduino Duemilanove ATmega 328
  • Arduino WIZnet Ethernet Shield
  • Tri color LED

Infrastructure

  • Internet access with DHCP, no public IP address needed for Arduino
  • (Optional: PC or Cloud Server with a public IP address, to run Yaler)

 

LED Test

FBD0UFIG5FQZWRL.MEDIUM

// HelloLed.pde

int redPin = 6;
int greenPin = 5;
int bluePin = 3;

void setColor (int red, int green, int blue) {
  // SparkFun LED: write value for each color
  //analogWrite(redPin, red);
  //analogWrite(greenPin, green);
  //analogWrite(bluePin, blue);

  // Ladyada LED: write inverted value for each color
  analogWrite(redPin, 255 - red);
  analogWrite(greenPin, 255 - green);
  analogWrite(bluePin, 255 - blue);

  delay(1000);
}

void setup () {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop () {
  setColor(0, 0, 0); // Off
  setColor(255, 0, 0); // Red
  setColor(0, 255, 0); // Green
  setColor(0, 0, 255); // Blue
  setColor(0, 255, 255); // Aqua
  setColor(255, 255, 0); // Yellow
  setColor(255, 0, 255); // Fuchsia
  setColor(255, 255, 255); // White
}

 

Accessing and controlling the Arduino from the Web

FHVYO1IGC4G0PNR.MEDIUM

If everything works as intended, you should see a simple HTML page with three colored buttons . If you press a button, the Arduino LED should light up in the corresponding color.

Behind the scenes this works with a simple Javascript that sends an HTTP PUT request , e.g. PUT http://try.yaler.net/gsiot-ffmq-ttd5/led/ff0000 to the Arduino to set the LED’s color. You can use Firefox with the Firebug add-on set to Net > XHR to see the PUT requests.

Note that the URL does not depend on the current location of the Arduino. No matter if it’s attached to your home network or to the LAN at your office, the URL remains the same. Just plug in the Arduino and control it with your browser.

Because typing the URL can be cumbersome, you can make use of a QR-Code generator like http://qrcode.kaywa.com/ to get a QR-Code of your Arduino’s URL (example below).

Print it, stick it to your Arduino, access it with a QR-Code reader like Lynkee(iPhone), Kaywa (Symbian, Java phones) or Quickmark (Windows Mobile) and there you have a switch-less, yet conveniently controllable Arduino.

Source : http://www.instructables.com/id/Arduino-Web-LED/

COMMENTS

Please Login to comment
  Subscribe  
Notify of