Hi,
I'll start by saying that i'm extremely freaked out by the fact that someone by the name of mercer (also my surname) has posted almost the exact question that I want to ask.
I've only just joined this forum and this is my first post.
I am a student working on my final year project and I want to control an Arduino Uno with Ethernet Shield and DMX shield from a browser interface.
I have so far managed to use just the Uno and Ethernet Shield to control 3 LEDs using a form created by editing some example code i found.
It's worth mentioning that I am a complete novice at writing/understanding code and I havent got much time to learn.
I havent bought or tried anything with a DMX shield yet either.
This is the code I currently have:
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE9, 0x21 };
IPAddress ip(192,168,1,177);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup()
{
Serial.begin(9600); // open up serial port connection to PC
pinMode(5, OUTPUT); // Set digital pin 5, 6, 3 as output
pinMode(6, OUTPUT);
pinMode(3, OUTPUT);
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
}
void showLEDstatus (EthernetClient client){
if (digitalRead(5)){ // 1<-- Display LED status
int val = analogRead (5);
client.print("RED LED is ON: ");
client.print(val);
client.println("<br />");
}else{
client.print(" RED LED is OFF");
client.println("<br />");
}
if (digitalRead(6)){ // 1<-- Display LED status
int val = analogRead (6);
client.print(" YELLOW LED is ON: ");
client.print(val);
client.println("<br />");
}else{
client.print(" YELLOW LED is OFF");
client.println("<br />");
}
if (digitalRead(3)){ // 1<-- Display LED status
int val = analogRead (3);
client.print(" Green LED is ON: ");
client.print(val);
client.println("<br />");
}else{
client.print(" Green LED is OFF");
client.println("<br />");
}
client.println("<br />");
}
void loop()
{
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
String buffer = ""; // Declare the buffer variable
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.print(c); // Send every character read to serial port
buffer+=c; // Assign to the buffer
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
showLEDstatus (client);
// 2<-- Create a form
client.print("<FORM action=\"
http://192.168.1.177/\" >");
client.print("<P> <INPUT type=\"radio\" name=\"statusred\" value=\"1\"> RED ON\n");
client.print("<P> <INPUT type=\"radio\" name=\"statusred\" value=\"0\"> RED OFF\n");
client.print("<P> <INPUT type=\"radio\" name=\"statusyel\" value=\"1\"> YELLOW ON\n");
client.print("<P> <INPUT type=\"radio\" name=\"statusyel\" value=\"0\"> YELLOW OFF\n");
client.print("<P> <INPUT type=\"radio\" name=\"statusgre\" value=\"1\"> GREEN ON\n");
client.print("<P> <INPUT type=\"radio\" name=\"statusgre\" value=\"0\"> GREEN OFF\n");
client.print("<P> <INPUT type=\"submit\" value=\"Go\"> </FORM>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
buffer=""; // Clear the buffer at end of line
} else if (c == '\r') {
if(buffer.indexOf("GET /?statusred=1")>=0)
digitalWrite(5, HIGH); // Catch ON status and set LED
if(buffer.indexOf("GET /?statusred=0")>=0)
digitalWrite(5, LOW); // Catch OFF status and set LED
if(buffer.indexOf("GET /?statusyel=1")>=0)
digitalWrite(6, HIGH); // Catch ON status and set LED
if(buffer.indexOf("GET /?statusyel=0")>=0)
digitalWrite(6, LOW); // Catch OFF status and set LED
if(buffer.indexOf("GET /?statusgre=1")>=0)
digitalWrite(3, HIGH); // Catch ON status and set LED
if(buffer.indexOf("GET /?statusgre=0")>=0)
digitalWrite(3, LOW); // Catch OFF status and set LED
}
else {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}
I have no idea how i would integrate DMX output code so that it could be controlled by 0-255 faders for red green and blue on the browser.
Thanks in advance for any help.