Maker Pro
Maker Pro

How does web page send data to port of computer

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:
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>
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.
 
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.
I have to write proogram only or I just need to install WAMP' stack
 
I have to write proogram only or I just need to install WAMP' stack
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.
 
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:
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 ?
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.
 
Top