i'm not really a bumblebee
romillyhills.co.uk uses cookies! cookies are used for the login system and removing this bubble.
clock16:38 on 19.01.14 eye2737 speech bubble0
yes, it's crude, yes, those are crocodile clips holding it together, but it's finally done, the classic project, the internet lamp. with pwm. here is a very short write-up for the project, which should be used more as a reference then a tutorial.

the idea is simple, turn on a light from your browser. i would have done my own version much sooner if i weren't afraid of mains power.

this uses an arduino uno, ethernet shield and some high brightness sparkfun leds [available from proto-pic in the uk]. the setup for these leds can be found in a sparkfun tutorial.

unfortunately i started this project a *very* long time ago, many of the details are lost, so i won't take credit for the code or give detailed explanations. but this is how i did it.

first we have a circuit, here we have the arduino, a physical button, an npn transistor and the lamp.

the mains supply i used was just an old adapter i had lying around which supplies +12V and also powers the arduino. the arduino is running the code:
#include SPI.h //had to remove the triangle brackets for the blog
#include Ethernet.h

boolean reading = false;
byte mac[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // put your mac address here
int moo=250; //brightness of leds
int poo=0; //prevents the button triggering too often
int led=9;
int button=8;
boolean on = false;

EthernetServer server = EthernetServer(80);

void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);

if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);

void loop(){
// listen for incoming clients, and process qequest.
if (poo==0){ //physical button toggles on/off
if (digitalRead(button)==HIGH) {
if (digitalRead(button)==LOW) {
analogWrite(led, moo);
analogWrite(led, 255);

void checkForClient(){
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;

while (client.connected()) {
if (client.available()) {

char c = client.read();
if(reading && c == ' ') reading = false;
if(c == '?') reading = true; //found the ?, begin reading the info

if(reading && c!='?'){

if(c=='0'){ //set brightness depending on input
}else if(c=='1'){
}else if(c=='2'){
}else if(c=='3'){

if (c == '\n' && currentLineIsBlank) break;
client.stop(); // close the connection:

which is only briefly commented. to turn the light on just enter the ip of your arduino [which it will output to the serial connection] into your browser, followed by /?1, for example

to change the brightness enter a value from 0-3, 0 being off, 3 being full brightness.

some interesting points to note if you try this yourself; to turn the leds off, you ground the adj pin. for this reason there is the grounded transistor for arduino control. the arduino ground was also not sufficient to turn off the leds, the mains ground was *needed* to turn it off fully.
what happened to my arms!?