The arduino light switch.



Here is a web based interface to control some low voltage lines via the
Arduino.  The web interface will let you either singly turn an led on of off. You can also turn all the leds on or off at one time. From there you can interface all kinds of equipment.  The basic circuit for the project is:




Or to look at an Arduino board the relevant pins are:




Whether is is for a Personal computer or one of many microcontrollers, the interfacing technique is pretty much the same. Here are two links to consider:

http://www.instructables.com/id/Ubuntu-and-the-arduino/

 http://www.instructables.com/id/External-device-control-ie-coffee-machine/

Now you can remotely turn on for off many devices and a start at home automation.

The code:
[code]
#include <Ethernet.h>

#include <SPI.h>

//network NB: Pins 10, 11, 12 and 13 are reserved for Ethernet module.

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte ip[] = { 192, 168, 1, 200 };

byte gateway[] = { 192, 168, 1, 1 };

byte subnet[] = { 255, 255, 255, 0 };

String inString = String(35);

String Led;
String z;

int led[] = {00, 1, 2, 3, 4, 5, 6, 7, }; //Led pins num 0 in arry is not used

int numofleds = 6; //numofleds

String value[] = {"on","on","on","on","on","on","on","on","on"}; //startup all led are off

EthernetServer server(80);

String data;

void setup()

{

Serial.begin(9600);

Ethernet.begin(mac, ip,gateway,subnet);

server.begin();

//set pin mode

for (int j = 2; j < (numofleds + 1); j++){

pinMode(led[j], OUTPUT);

}

Serial.println("Serial READY");

Serial.println("Ethernet READY");

Serial.println("Server READY");

}

void loop()

{

EthernetClient client = server.available();

if(client){

// an http request ends with a blank line

boolean current_line_is_blank = true;

while (client.connected()) {

if(client.available()) {

char c = client.read();

// if we've gotten to the end of the line (received a newline

// character) and the line is blank, the http request has ended,

// so we can send a reply

if (inString.length() < 35) {

inString.concat(c);

}

if (c == '\n' && current_line_is_blank) {

// send a standard http response header

client.println("HTTP/1.1 200 OK");

client.println("Content-Type: text/html");

client.println();

client.println("<html><body><form method=get>");

client.println("<hr><center>");
client.println("<p>Led controller</p>");
client.println("</center><hr>");

client.println("<p>Each led</p>");

for(int i=2;i < (numofleds + 1) ;i++){

Led = String("Led") + i;
z = String("#") + i;
if(inString.indexOf(Led+"=on")>0 || inString.indexOf("all=on")>0){

Serial.println(Led+"on");

digitalWrite(led[i], HIGH);

value[i] = "off";

}else if(inString.indexOf(Led+"=off")>0 || inString.indexOf("all=off")>0 ){

Serial.println(Led+"off");

digitalWrite(led[i], LOW);

value[i] = "on";


}

client.println("<br> Led "+z+"  <input type=submit name="+Led+" value="+value[i]+">");

}

client.println("<p>All leds</p>");
client.println("<input type=submit name=all value=on><input type=submit name=all value=off>");

client.println("</form><html></body>");

break;

}

if (c == '\n') {

// we're starting a new line

current_line_is_blank = true;

} else if (c != '\r') {

// we've gotten a character on the current line

current_line_is_blank = false;

}

}

}

// give the web browser time to receive the data

delay(10);

inString = "";

client.stop();

}

}
[/code]

Update:

 
Computer controlled audio switcher.   If you have a podcast it would be nice to be able to add or remove inputs. Can be very easy to do with the computer. remotely. The Rpi or an ethernet enabled arduino would be good for this. You will need cmos 4066 chips and 5 stereo inout jackes to complete the hardware. More details later.to do with the computer. remotely. The Rpi or an ethernet enabled arduino would be good for this. You will need cmos 4066 chips and 5 stereo input jacks to complete the hardware. More details later.















Set of 4066 chips









Microcontroller to the 4066 chips

Screenshot from 2013-09-24 04:54:51.png



















Screenshot from 2013-09-24 03:44:49.png









Single 4066 chip


Screenshot from 2013-09-24 04:28:44.png















Connectors

SUNP0031.JPG

Comments

Popular posts from this blog

Guiless?

MSOffice vs Libreoffice

Raspberry pi zero.