Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Bridge.h>
- #include <YunServer.h>
- #include <YunClient.h>
- const byte internalLED = 13;
- YunServer server;
- void setup() {
- pinMode(internalLED, OUTPUT);
- digitalWrite(internalLED, HIGH); // Turn the led on to advise about bridge begin in progress
- Bridge.begin(); // Let's activate the Yun Bridge...
- ledBlink(150); // ...bridge activation done (user sees a blink)
- // server.listenOnLocalhost(); // Listen for incoming connection only from localhost (no one from the external network could connect)
- server.begin(); // Let's acrivate the Yun server...
- ledBlink(150); // ...server activation done (user sees a blink)
- }
- void loop() {
- YunClient client = server.accept(); // Get clients coming from server
- if (client) // Is there a new client?
- {
- client.print(77); // Send a "77" to client (e.g. browser)
- client.stop(); // Close connection and free resources.
- ledBlink(500);
- }
- delay(50);
- }
- void ledBlink(int delayTime) {
- digitalWrite(internalLED, HIGH); // Turn (or keep) the LED on
- delay(delayTime);
- digitalWrite(internalLED, LOW); // Turn (or keep) the LED off
- delay(delayTime);
- }
- http://192.168.1.98/arduino/whatever
- <!DOCTYPE html>
- <html>
- <head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
- <script>
- $.get("http://192.168.1.98/arduino/whatever", {}, function(data,status){
- alert("Data: " + data + "nStatus: " + status);
- });
- </script>
- </head>
- <body></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement