Show Posts
Pages: [1]
1  Using Arduino / LEDs and Multiplexing / Basic WebClient for controlling LED on: May 24, 2013, 07:15:01 pm
Hello,
I want to control 2 LEDs with using my html page(webb.html). I read the tutorials and created a system.
My simple html page's code;
Code:
<!DOCTYPE html>
<html>
<body>     
          <FORM >
          <P> <INPUT type="radio" name="status" value="1">ON
          <P> <INPUT type="radio" name="status" value="0">OFF
          <br />
          <br />
          <P> <INPUT type="radio" name="status" value="2">ON
          <P> <INPUT type="radio" name="status" value="3">OFF
          <P> <INPUT type="submit" value="Submit"> </FORM>
</body>
</html>

My arduino code;
Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(myserverIp);

IPAddress ip(192,168,1,4);

EthernetClient client;

void setup() {
 
  Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
   
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
   
    Ethernet.begin(mac, ip);
  }
 
  delay(1000);
 
  Serial.println("connecting...");

  if (client.connect(server, 80))
  {
    Serial.println("connected");
    client.println("GET /webb.html HTTP/1.1 200 OK");
    client.println("Host: www.myhost.net");
    client.println("Connection: close");
    client.println();
  }
  else
  {
    Serial.println("connection failed");
  }
}

void loop()
{
  while (client.connected()) {
  if (client.available())
  {
    boolean currentLineIsBlank = true;
    String buffer = "";
    char c = client.read();
    Serial.print(c);
    buffer+=c;
     
    if (c == '\n') {
         
          currentLineIsBlank = true;
          buffer="";       
        } else if (c == '\r') {           
          if(buffer.indexOf("GET /?status=1")>=0)
            digitalWrite(3,HIGH); 
         
          if(buffer.indexOf("GET /?status=0")>=0)
            digitalWrite(3,LOW);
           
           
          if(buffer.indexOf("GET /?status=2")>=0)
            digitalWrite(4,HIGH);
           
          if(buffer.indexOf("GET /?status=3")>=0)
            digitalWrite(4,LOW);
        }
        else {
         
          currentLineIsBlank = false;
        }
  }

  if (!client.connected())
  {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    while(true);
  }
  }
}
And when i upload this code to my arduino, i get this in serial monitor;
Code:
connecting...
connected
HTTP/1.1 200 OK
Date: Fri, 24 May 2013 23:37:59 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Fri, 24 May 2013 22:12:05 GMT
ETag: "ba41800-1b4-4dd7e16cd1740"
Accept-Ranges: bytes
Content-Length: 436
Vary: Accept-Encoding
X-Powered-By: PleskLin
Connection: close
Content-Type: text/html

<!DOCTYPE HTML>
<body>     
          <FORM >
          <P> <INPUT type="radio" name="status" value="1">ON
          <P> <INPUT type="radio" name="status" value="0">OFF
          <br />
          <br />
          <P> <INPUT type="radio" name="status" value="2">ON
          <P> <INPUT type="radio" name="status" value="3">OFF
          <P> <INPUT type="submit" value="Submit"> </FORM>
</body>
</HTML>
             
disconnecting.

When I choose first radio on my html page to set my pin3 to turn on the LED,  i can't get any result.
What am i missing? Or where did i make mistake?

Please help me to fix this.

Best Regards..
2  Using Arduino / Project Guidance / Re: Lighting control(Arduino-Android) on: November 26, 2012, 03:57:13 pm
I got it now. Thanks a lot for your whole help. You told me all i need with your patience. I appreciate that.
Best regards...
3  Using Arduino / Project Guidance / Re: Lighting control(Arduino-Android) on: November 26, 2012, 01:55:20 pm
I understand all thing you told me except this;
Quote
Do you have to write an Android app? If you need to have a web interface for the people outside of the city, then why not just use that same interface with a the Arduino's browser?
Yes, there suppose to be android app. With computer control part i can use arduino's browser. But with phone control part i have to create a basic android app. I think if i hook up my android app and Arduino's browser, my problem will be solved. If it is not possible, i need to create 1 for computer and 1 for phone?
And I decided to buy this equipments => 'Arduino UNO R3' and 'Arduino Ethernet Shield Rev3 WITH PoE Module'.
I really look forward to start coding if i understand this last problem...
4  Using Arduino / Project Guidance / Re: Lighting control(Arduino-Android) on: November 26, 2012, 11:18:12 am
Well, i understand that making whole project without wire is too hard for a beginner like me. I searched a bit more and i found this video =>' ' That guy made a project. I think i can make project like that. He is also using an IP to connect with system. But the first diffrence his project and mine is = At the end of the video he controlled lights also with his iPad. But in my project i want to control with my android application. It will be simple application. When i run the application, application wants to connect internet. And i will reach the IP which i gave it. Then i will control lights.(But i dont know in this part do i need an android development kit for my arduino?).
The second diffrence as i said is my lights need to control other cities which are closer my city.
I dont have to use Arduino Mega ADK. I thought, my project will has android application for control. Thats why i said that. Equipments were my thoughts. We can change them. Cheaper way will be best for me. So, according to that video and my requests, am I gonna need 1 arduino, 1 ethernet shield, 1 solid state relay? But arduino and ethernet shields have a lot of types. I dont know which ones are best for me?
5  Using Arduino / Project Guidance / Re: Lighting control(Arduino-Android) on: November 25, 2012, 06:35:40 pm
Thanks for replied. Firstly, i wanna control only 1 light. The main idea in my project is being Android project. I have to make an android application for this. In hardware part i chose arduino. Because i worked a bit with it. Project must be wireless, because my project has to supply controlling my light in other cities via internet. In this case i want to give a static IP to my light. With this way we can reach system when we write this IP to phone or computer.
The close by part is when i run my android application on my phone, it connect with arduino and do what i want(open or close light). And also this part will be wireless.
Arduino for this project must supply ADK, and i found 'Arduino Mega ADK'. For controlling for other cities need 'Arduino Ethernet Shield w/o PoE R3'. But i dont know what can i use when i close by? dont know Ethernet shield is enough for it? If not enough, i need wireless shield or bluetooth shield?
I am sorry for asked a lot of things. As i said i am new with arduino and my knowledge is limited.
6  Using Arduino / Project Guidance / Lighting control(Arduino-Android) on: November 25, 2012, 09:35:23 am
Hello everyone;
Home Automation Lighting is what i am gonna do. In my project we can control lights using computer via internet(I think with arduino web server). Also control with my android phone. I want to make an android application for this.
But i am not sure which arduino is fit to my project. I think 'Arduino Mega ADK' and 'Arduino Ethernet Shield w/o PoE R3' is enough for me. I dont know this things is compatible for each other. I worked with arduino in my erasmus term. I only made LED blinking etc. But i liked arduino and wanna do this project. So, I am new with arduino. I dont wanna buy wrong things. Please help me to choose and give me hint for good starting.
Best regards...
7  Topics / Home Automation and Networked Objects / Re: Home Automation Lighting on: November 25, 2012, 09:15:28 am
Hello everyone;
Home Automation Lighting is exactly what i am gonna do. In my project we can control lights using computer via internet(I think with arduino web server). Also control with my android phone. I want to make an android application for this.
But i am not sure which arduiono is fit to my project. I think 'Arduino Mega ADK' and 'Arduino Ethernet Shield w/o PoE R3' is enough for me. I dont know this things is compatible for each other. I am new with arduino. I dont wanna buy wrong things. Please help me to choose and give me hint for good starting.
Best regards...
8  Topics / Home Automation and Networked Objects / Re: Home Automation Lighting on: November 23, 2012, 06:04:28 pm
Hello everyone;
Home Automation Lighting is exactly what i am gonna do. In my project we can control lights using computer via internet(I think with arduino web server). Also control with my android phone. I want to make an android application for this.
But i am not sure which arduiono is fit to my project. I think 'Arduino Mega ADK' and 'Arduino Ethernet Shield w/o PoE R3' is enough for me. I dont know this things is compatible for each other. I am new with arduino. I dont wanna buy wrong things. Please help me to choose and give me hint for good starting.
Best regards...
Pages: [1]