Arduino Forum

Products => Arduino Yún => Topic started by: haconmagnus on Jan 29, 2016, 02:11 am

Title: Light an Led when a webpage is loaded ?
Post by: haconmagnus on Jan 29, 2016, 02:11 am
Hello to all first post here. I recently picked up a Yun. I have done a few of the basic example sketches as well as written a simple webpage to control 2 led lights. I am just getting started coding on arduino and would greatly appreciate some help with an idea that I had when I made the led control webpage.

Like the title says , what I want to do is instead of turning on and off a led from a webpage, I want to light an led when a webpage is loaded.

Example:
You have a webserver setup and when a specific page is loaded LED lights up.

The webserver is running on a windows machine (apache), PHP is present as well as mysql the yun would be local to that machine.

Regards
Title: Re: Light an Led when a webpage is loaded ?
Post by: haconmagnus on Jan 29, 2016, 04:39 pm
I actually figured out a simple way to do this and have it working mint.
Title: Re: Light an Led when a webpage is loaded ?
Post by: ShapeShifter on Jan 29, 2016, 06:21 pm
Why don't you share your solution with us? It may help the next person.

As I understand it, the page is being served by a server on a different computer, but you want the Yun to react to a specific page being loaded? Seems to me you would need some JavaScript on the page being served that makes a request to the Yun (probably a REST API?) to control the LED. Or, the page could include a specific item, like an image (even if it's a 1 pixel invisible image) that is requested from the Yun, so that loading the page would automatically make a request to the Yun. My last idea is to have a CGI script on the remote server that accesses an API on the Yun when the page is loaded.

So, what solution did you discover?
Title: Re: Light an Led when a webpage is loaded ?
Post by: haconmagnus on Jan 30, 2016, 01:23 am
greetings
My original way of thinking was like you to use something like a java script but the more I thought about it I wanted to keep it as simple as possible, So I had the exact idea you posted

"the page could include a specific item, like an image (even if it's a 1 pixel invisible image) that is requested from the Yun, so that loading the page would automatically make a request to the Yun."

works perfectly.