Go Down

Topic: push button to web link [SOLVED] (Read 1 time) previous topic - next topic

psyazax

Dec 01, 2012, 04:13 pm Last Edit: Dec 11, 2012, 12:56 am by psyazax Reason: 1
Hello to everyone

i know that almost everybody want to control pin's over the web but for me is other way around

it is possible to have 5 push button on arduino and when i press some of the buttons arduino to access web link ?

let say

push button 1  -> http://192.168.7.10/link1.php
push button 2  -> http://192.168.7.10/link2.php
...
push button 5  -> http://192.168.7.10/link5.php

the reason i need this is because i have web server with web site.. and from there im controling some hardwere

i was searching over internet 3 weeks to find something but i did not :/


zoomkat

You would probably use web client code on the arduino to send data in a get or post to the remote web server.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

johnwasser

Did you look at the two Web Client examples?  Should be fairly easy to adapt one to make the web requests you want.

Code: [Select]

IPAddress server(192,168,7,10);
 if (client.connect(server, 80)) {
   Serial.println("connected");
   // Make a HTTP request:
   client.println("GET /link1.php HTTP/1.0");
   client.println();
 }
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Aries

#3
Dec 02, 2012, 10:45 pm Last Edit: Dec 02, 2012, 10:48 pm by Aries Reason: 1
Hey there.

This is my first contact with arduino and related devices.
This thread seems to at least partly contain a way to my target:
I have a home automation miniserver (www.loxone.com) which also can interpret UDP commands. So, I think about a way to build up a kind of (stand alone) single room controller, consisting of a simple keypad in each room, which sends an impuls to the arduino device whereas each key is intended to launch an UDP signal.

Is this possible and what devices would I have to purchase for such a project?


Thanks in advance for any hint, Aries.

psyazax

thanks everybody for replaying

i make modification from this sketch

http://arduino.cc/forum/index.php/topic,60996.0.html



Code: [Select]

#include <SPI.h>
#include <Ethernet.h>
#include <Client.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:

// MAC address
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,0,50 };
byte server[] = { 192,168,0,100 }; // mio computer

Client client(server, 80);
// pin button:
const int button2Pin = 2;     // the number of the pushbutton pin
const int button3Pin = 3;

// variables will change:
int button2State = 0;     
int button2StateOld = 0; // variable for reading the pushbutton status
int button3State = 0;     
int button3StateOld = 0; // variable for reading the pushbutton status


// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):





void setup() {

 
  // initialize the pushbutton pin as an input:
  pinMode(button2Pin, INPUT);
  pinMode(button3Pin, INPUT); 
    // start the Ethernet connection:
Ethernet.begin(mac, ip);
  // initialize serial:
  Serial.begin(9600);
  // initialize ethernet:
  delay(1000);
  Serial.println("connecting...");
  // if connect show on serial:
  if (client.connect())
  Serial.println("connected");
   
else {
  // if not connect:
  Serial.println("connection failed");
  }
}


void loop ()
{
  loop1 ();
  loop2 ();
}


void loop1 ()
{
        button2StateOld=button2State;
        button2State = digitalRead(button2Pin);
 
    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (button2State != button2StateOld)  {
                  if (button2State == HIGH){
                           client.connect();
                           Serial.println("pin2 high");
                           client.println("POST /link1.php");
                           client.println();
                           client.stop();}
                    }

     
          delay (500);//end delay before loop starts again
}
void loop2 ()
{
        button3StateOld=button3State;
        button3State = digitalRead(button3Pin);
 
    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (button3State != button3StateOld)  {
                  if (button3State == HIGH){
                           client.connect();
                           Serial.println("pin3 high");
                           client.println("POST /link2.php");
                           client.println();
                           client.stop();}
                    }

     
          delay (500);//end delay before loop starts again
}


what do you think ? its good ? can i make improvements  ?

ksduino

Hi,

I have introduced our new project KSduino in the 'ksduino' topic of this forum group. You can connect you Arduino to the KSduino web site and monitor & control your device through internet.

It may be is interesting for you,

see the KSduino web site: http://ksduino.org  and the 'ksduino' topic: http://arduino.cc/forum/index.php/topic,136475.0.html
Best regards,
Kirill Scherba.
http://ksduino.org

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview