Offline
Newbie
Karma: 0
Posts: 7
|
 |
« on: September 13, 2011, 09:43:55 am » |
Hello, i'm needing a source code for HMTL Button to turn ON and turn OFF a port of arduino with Ethernet Wiznet...
|
|
|
|
|
Logged
|
|
|
|
|
Vejen, Denmark
Offline
Edison Member
Karma: 7
Posts: 1176
RAWR! ^,..,^
|
 |
« Reply #1 on: September 13, 2011, 09:49:37 am » |
Hello, i'm needing a source code for HMTL Button to turn ON and turn OFF a port of arduino with Ethernet Wiznet...
Do you expect someone to just make it for you, or do you plan on putting some effort in yourself too? Have you tried searching? I just did, and found some projects involving exactly this. And lastly, it looks like you already asked it here too http://arduino.cc/forum/index.php/topic,72201.msg540477.html#msg540477 another language, but still, double posting only leads to more frustrations than results.
|
|
|
|
« Last Edit: September 13, 2011, 09:53:45 am by bld »
|
Logged
|
|
|
|
|
Hamburg, Germany
Offline
Full Member
Karma: 2
Posts: 190
Hello world!
|
 |
« Reply #2 on: September 14, 2011, 10:59:07 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #3 on: September 15, 2011, 09:45:00 am » |
Thank you for the link, very helpful! Unlike other users who talk a lot but do not add anything.
|
|
|
|
|
Logged
|
|
|
|
|
Vejen, Denmark
Offline
Edison Member
Karma: 7
Posts: 1176
RAWR! ^,..,^
|
 |
« Reply #4 on: September 15, 2011, 10:29:16 am » |
Thank you for the link, very helpful! Unlike other users who talk a lot but do not add anything.
By that, I guess you didn't do what I suggested, to search for it. If you had done that, you would have found what you needed too. But well, easier to just have others do the work, instead of actually having to figure it out.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #5 on: September 15, 2011, 11:53:51 am » |
sui, I put this code in my ArduinoUno and is now available. To test I'm trying to turn off the digital port 13 (which already has an LED). I changed the "int RCTransmissionPin = 7;" to 13 but did not work. You know how to do?
|
|
|
|
|
Logged
|
|
|
|
|
Harlow, Essex, UK
Offline
Jr. Member
Karma: 1
Posts: 67
|
 |
« Reply #6 on: September 15, 2011, 12:13:04 pm » |
arduinohtml - Like yourself I am very new to Arduinos and the programming environment having bought my first Arduino only 6 weeks ago.
There are many useful resources available within this forum, but i think you need to start at the begining and learn the basics before jumping in the deep end. This will give you a good platform to learn from.
Within the Arduino programming environment, click on FILE, EXAMPLES, BASICS there you will find some basic examples and I suggest you start wit BLINK.
With these forums, its always best to post some code and ask for assistance so people can see what you are trying to achieve.
With the help of one board member particulalry, I have learnt an awful lot and been very appriciative, so there are good people on this forum.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6526
Arduino rocks
|
 |
« Reply #7 on: September 15, 2011, 06:20:30 pm » |
Very simple web based gui for turning pin 4 on and off. //zoomkat 9-5-11 //routerbot code //for use with IDE 0021 //open serial monitor to see what the arduino receives //use the \ slash to escape the " in the html //address will look like http://192.168.1.102:84/ when submited //for use with W5100 based ethernet shields
#include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 102 }; // ip in lan byte gateway[] = { 192, 168, 1, 1 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask Server server(84); //server port
String readString;
//////////////////////
void setup(){
pinMode(4, OUTPUT); //pin selected to control //start Ethernet Ethernet.begin(mac, ip, gateway, subnet); server.begin();
//enable serial data print Serial.begin(9600); Serial.println("servertest1"); // so I can keep track of what is loaded }
void loop(){ // Create a client connection Client 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
//now output HTML data header if(readString.indexOf('?') >=0) { //don't send new page client.println("HTTP/1.1 204 Zoomkat"); client.println(); client.println(); } else { 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>Arduino GET test page</TITLE>"); client.println("</HEAD>"); client.println("<BODY>");
client.println("<H1>Zoomkat's simple Arduino button</H1>"); client.println("<a href=\"/?on\" target=\"inlineframe\">ON</a>"); client.println("<a href=\"/?off\" target=\"inlineframe\">OFF</a>");
//client.println("<IFRAME name=inlineframe src=\"res://D:/WINDOWS/dnserror.htm\" width=1 height=1\">"); client.println("<IFRAME name=inlineframe style=\"display:none\" >"); client.println("</IFRAME>");
client.println("</BODY>"); client.println("</HTML>"); }
delay(1); //stopping client client.stop();
///////////////////// control arduino pin if(readString.indexOf("on") >0)//checks for on { digitalWrite(4, HIGH); // set pin 4 high Serial.println("Led On"); } if(readString.indexOf("off") >0)//checks for off { digitalWrite(4, LOW); // set pin 4 low Serial.println("Led Off"); } //clearing string for next read readString="";
} } } } }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #8 on: September 15, 2011, 09:51:47 pm » |
Zoomkat, exactly what I needed to find my problem. I put this code on my Arduino and it worked. The problem is that Google Chrome, click the "OFF" it flashes the pin 4 and turn on again. Already IExplorer8 by clicking on "OFF" it really turns off pin 4 normally. How the browser works requests are generating this flaw in this code. Have you seen this problem?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6526
Arduino rocks
|
 |
« Reply #9 on: September 16, 2011, 02:18:07 am » |
Have you used the serial monitor to see if something different is being sent to the arduino from the different brousers?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 29
Arduino rocks
|
 |
« Reply #10 on: September 16, 2011, 05:43:11 am » |
Hi, as I've read this post, I' ve decided to start working on my Ethernet Shield. I've tried out the code given by Zookmat. It seems the Ethernet part of the code is working fine, but the led ( I used the PIN 13 one), is not lighting up. In serial monitor I receive this output: servertest1 GET /?on HTTP/1.1
Led On GET /?off HTTP/1.1
Led Off GET /?on HTTP/1.1
Led On
Ofc I' ve written 13 where there was the 4 as pin. Also the code seems correct, I don't find any apparent error, it just seems Arduino is ignoring the instruction:
digitalWrite(13, HIGH);
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6526
Arduino rocks
|
 |
« Reply #11 on: September 16, 2011, 10:59:24 am » |
It seems the Ethernet part of the code is working fine, but the led ( I used the PIN 13 one), is not lighting up. I forget the reason, but I don't think you can use pin 13 with the ethernet library. If you look close at the pin 13 led, it appears to be turning on/off very rapidly. I test the setup just by connecting my multimeter to pin 4 and watch the voltage change when the buttons are used.
|
|
|
|
|
Logged
|
|
|
|
|
Sussex UK / CT USA
Offline
Edison Member
Karma: 0
Posts: 1026
Forums forever
|
 |
« Reply #12 on: September 17, 2011, 08:29:36 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 29
Arduino rocks
|
 |
« Reply #13 on: September 19, 2011, 09:20:37 am » |
Great work Zoomkat, indeed it works very fine, using other pins. Thank to this now i can switch on/off my HVAC at home even if I'm at work and I can restart my dsl router that unfortunately locks up too often at work. Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Vejen, Denmark
Offline
Edison Member
Karma: 7
Posts: 1176
RAWR! ^,..,^
|
 |
« Reply #14 on: September 19, 2011, 11:20:03 am » |
work and I can restart my dsl router that unfortunately locks up too often at work.
How are you going to contact it when the router is stalled?
|
|
|
|
|
Logged
|
|
|
|
|
|