0

I need an Arduino to send a message, to be displayed on the web, after pressing a push button, which is connected to an Arduino [or shield], without using a GSM shield.

I need to send a message just by using HTML/PHP code included in the Arduino IDE. This displayed message should contain two buttons. One button is used to turn a LED ON/OFF and the other to open a streaming video.

Can anyone help me with the Arduino code and explain how I should do that? Is there any third party device, apart from a GSM shield, that can help me to send that message?

  • Start with either the Ethernet shield or the WiFi shield. – CharlieHanson Nov 11 '15 at 19:52
  • I'm trying to understand what you really want, do you want your arduino to provide some sort of webpage containing two buttons. one to turn on a LED and the other one is used to open a streaming video? Is that what you want? Also, I feel myself confused about the buttons, which ones are the physical buttons and which ones are meant to be on the webpage? – Ikbel Nov 11 '15 at 19:56
  • yes, thats what i want exactly. i want arduino to provide a message after pressing a button and the message must display on web shows 2buttons. one phyiscally connected to arduino and used to turn on/off led and the other button on the webpage to open a stream vedio/audio. Now do you understand what i want. and if yes, can you help me with arduino code? – Rania Nov 11 '15 at 23:08
  • note: i deal with Ethernet shield. and i need html and php code for control LED and open a stream video. additionally, without using a GSM sheild to let arduino send the message. – Rania Nov 11 '15 at 23:11
  • Yes I can help you, but have you tried something? What you need is to set up a Web Server on your arduino. You may look at this tutorial: arduino.cc/en/Tutorial/WebServer – Ikbel Nov 12 '15 at 3:15
1

Use this example to open a webpage using a push button, you need Python installed on your Windows.

Step 01:

Upload this sketch to your arduino:

const int buttonPin = 2; // the number of the pushbutton pin
int buttonState = 0;

void setup() {
  Serial.begin(9600);  
  pinMode(buttonPin, INPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
  Serial.println("OpenWebPage");
  }
}

The Circuit:

  • pushbutton attached to pin 2 from +5V
  • 10K resistor attached to pin 2 from ground

enter image description here

Step 02:

Open a text editor and paste this code to a new file:

import serial
from subprocess import call

ser = serial.Serial(
    port='COM5', # Change this to your COM port number
    baudrate=9600,
    parity=serial.PARITY_ODD,
    stopbits=serial.STOPBITS_TWO,
    bytesize=serial.SEVENBITS
)

if (ser.isOpen()):
    print "Serial Port is Open..."
    print "Waiting for a command ..."
    while 1:
        cmd = ser.readline()
        if cmd.strip() == "OpenWebPage":
            print "Received command from Arduino..." 
            print "Opening webpage..." 
            call(["explorer", "http://www.google.com"]) #change it the address you want

Save the file to your desktop, name it : SerialListener.py

Step 03

  • Now open a Command Prompt window.
  • Navigate to your desktop folder and execute this command: python SerialListener.py.
  • You should see Serial Port is Open... Waiting for a command ...
  • Press the push button, and a webpage should open in your default browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.