Goeiemiddag mensen
Ik ben momenteel bezig met een projectje met een arduino uno en arduino ethernet shield. Zo ver heb ik deze code om mijn pinnen te regelen:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xAF, 0xF6 }; //physical mac address
byte ip[] = { 192, 168, 50, 250 }; // ip in lan
byte gateway[] = { 192, 168, 50, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;
//////////////////////
void setup(){
pinMode(5, OUTPUT); //pin selected to control
pinMode(6, OUTPUT); //pin selected to control
pinMode(7, OUTPUT); //pin selected to control
pinMode(8, OUTPUT); //pin selected to control
pinMode(2, OUTPUT); //pin selected to control
//start Ethernet
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600);
Serial.println("server multi pin button test 1.0"); // so I can keep track of what is loaded
}
void loop(){
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE>Domotica Control Panel</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>Domotica Control Panel</H1>");
// For simple testing, pin 5, 6, 7, and 8 are used in buttons
// DIY buttons
client.println("<p>WandContactDoos 1.</p>");
client.println("<input type=submit value=ON style=width:100px;height:45px onClick=location.href='/?on2;'>");
client.println("<input type=submit value=OFF style=width:100px;height:45px onClick=location.href='/?off3;'>");
client.println(" <input type=submit value='ALL OFF' style=width:100px;height:45px onClick=location.href='/?off3579;'>");
// mousedown buttons
client.println("<p>WandContactDoos 2.</p>");
client.println("<input type=submit value=ON style=width:100px;height:45px onClick=location.href='/?on4;'>");
client.println("<input type=submit value=OFF style=width:100px;height:45px onClick=location.href='/?off5;'>");
client.println(" <input type=submit value='ALL OFF' style=width:100px;height:45px onClick=location.href='/?off3579;'>");
// mousedown radio buttons
client.println("<p>WandContactDoos 3.</p>");
client.println("<input type=submit value=ON style=width:100px;height:45px onClick=location.href='/?on6;'>");
client.println("<input type=submit value=OFF style=width:100px;height:45px onClick=location.href='/?off7;'>");
client.println(" <input type=submit value='ALL OFF' style=width:100px;height:45px onClick=location.href='/?off3579;'>");
// custom buttons
client.println("<p>WandContactDoos 4.</p>");
client.println("<input type=submit value=ON style=width:100px;height:45px onClick=location.href='/?on8;'>");
client.println("<input type=submit value=OFF style=width:100px;height:45px onClick=location.href='/?off9;'>");
client.println(" <input type=submit value='ALL OFF' style=width:100px;height:45px onClick=location.href='/?off3579;'>");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
///////////////////// control arduino pin
if(readString.indexOf('2') >0)//checks for 2
{
digitalWrite(5, HIGH); // set pin 5 high
Serial.println("Led 5 On");
}
if(readString.indexOf('3') >0)//checks for 3
{
digitalWrite(5, LOW); // set pin 5 low
Serial.println("Led 5 Off");
}
if(readString.indexOf('4') >0)//checks for 4
{
digitalWrite(6, HIGH); // set pin 6 high
Serial.println("Led 6 On");
}
if(readString.indexOf('5') >0)//checks for 5
{
digitalWrite(6, LOW); // set pin 6 low
Serial.println("Led 6 Off");
}
if(readString.indexOf('6') >0)//checks for 6
{
digitalWrite(7, HIGH); // set pin 7 high
Serial.println("Led 7 On");
}
if(readString.indexOf('7') >0)//checks for 7
{
digitalWrite(7, LOW); // set pin 7 low
Serial.println("Led 7 Off");
}
if(readString.indexOf('8') >0)//checks for 8
{
digitalWrite(8, HIGH); // set pin 8 high
Serial.println("Led 8 On");
}
if(readString.indexOf('9') >0)//checks for 9
{
digitalWrite(8, LOW); // set pin 8 low
Serial.println("Led 8 Off");
}
//clearing string for next read
readString="";
}
}
}
}
}
Ik heb nu rond gekeken op google en deze forum en ook andere forum's. Maar zo ver heb ik geen voorbeeld of iets wat me verder kon helpen gevonden.
Wat ik precies nog wil maken.
Per WCD een instelbare aflooptimer van 1 min tot 60 min als de timer actief is moet de pin omhoog gaan waar de timer mee verbonden is.
Momenteel is dit me HTML pagina layout:
http://nl.tinypic.com/view.php?pic=301fww2&s=5#.UoXuG_ldCeM Als de foto niet werkt gebruik dan deze link
Ik wil dus per WCD er achter een vakje hebben waar in ik een tijd kan instellen 1-60 min en dan daarnaast een Start knop.
Ik hoop dat dit genoeg informatie is om te begrijpen wat ik bedoel zo niet laat dan een reply achter met quote met stukje wat je niet snapt.
Cheers pewebob