Pages: [1]   Go Down
Author Topic: push button to web link [SOLVED]  (Read 1915 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :/

« Last Edit: December 10, 2012, 06:56:58 pm by psyazax » Logged

0
Offline Offline
Tesla Member
***
Karma: 147
Posts: 9741
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You would probably use web client code on the arduino to send data in a get or post to the remote web server.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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();
  }
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 02, 2012, 04:48:08 pm by Aries » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks everybody for replaying

i make modification from this sketch

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



Code:
#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  ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Best regards,
Kirill Scherba.
http://ksduino.org

Pages: [1]   Go Up
Jump to: