Connect with us

How does web page send data to port of computer

Discussion in 'Microcontrollers, Programming and IoT' started by vead, Mar 10, 2016.

Scroll to continue with content
  1. vead

    vead

    473
    14
    Nov 27, 2011
    Hello

    I have computer that has internet connection and Microcontroller is connected to computer via usb to db9 cable. LED is connected to port pin of microcontroller

    Computer -> web page (com port of PC)----- DB9 connector -> max Rs232 - > micro c -> LED

    I want to control LED via web page I have created a web page , there are two buttons on web page , start and stop, if I press start button on web page , led should be “on’’ and If I press stop button on web page ,led should be turn “off’’
    I am using Windows ,I want to send this information (LED ON/OFF) from internet to one of the serial ports of my computer? I am looking example code , can anyone tell me How does web page send data to port of computer ?
    HTML:
    <html>
    <head>
    <head>
    <body>
    start<input type=button name="start">
    stopt<input type=button name="stop">
    </html>
    
     
    Last edited: Mar 10, 2016
  2. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    The web-page does not send any information to a physical port on a computer.
    What you will NEED to do is write a script (with php for example) that receives a request from the web-site and toggles the pins or sends information to the port you want.
    You will need to install a 'WAMP' stack.
     
    vead likes this.
  3. vead

    vead

    473
    14
    Nov 27, 2011
    I have to write proogram only or I just need to install WAMP' stack
     
  4. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Both...
    You need a web-server at the very least.
    In addition to the web-server, you also need script support in the form of CGI, or PHP for example. (Those tend to be most common)
    'WAMP' stands for 'Windows, Apache, MySQL, PHP' and is a bundled software package to allow you to host things almost immediately.
    Once you have the proper programs to 'serve' files, you can then write a custom web-page that sends commands to the computer via CGI or PHP. The computer will then deal with port you want to manipulate.

    It's a bit to wrap your head around... but you need a 'back-end' to handle the dirty work... the 'front-end' is the webpage you 'see' when you visit the site.
    If you need examples, I'm sure there are TONS of resources available for the Raspberry Pi ... I know this may not be what you are working with, but the same steps required to make a Pi toggle a ping on and off is the same step required to make any other computer do something based on data sent from a web-page.
     
    vead likes this.
  5. vead

    vead

    473
    14
    Nov 27, 2011
    thank you very much for helping me ,I have to use C code to receive information on the microcontroller and PHP is used to send data. I don't have knowledge about PHP language. but I am reading some links , tutorials. also I saw some example code , can you tell me , what I have to write in program ?
     
    Last edited: Mar 11, 2016
  6. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Well, how about you stick with PHP for now then. Lots of resources, cross-platform, and it looks like you have at least touched PHP whereas CGI is a new thing...
    When you make a web-page, you can make it in HTML, or PHP ... the difference is when you access the web-page, the server will simply give you a copy of the HTML file. With PHP, the server will actually read it, and run it like a program. The 'output' of this program get's sent out, and that's what you see on the web-site.
    The simplest thing to try, is making a special 'page' that simply runs a program. You can see how here : http://php.net/manual/en/function.exec.php
    myhost.net/turn-port-on.php for example.
    When it comes time to make the web-page pretty, you can do it one of two ways:
    - Write HTML, and 'embed' PHP inside.
    - Write it all in PHP, and use this script to return/print 'HTML-like' code.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-