Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include <Bridge.h>
  2. #include <YunServer.h>
  3. #include <YunClient.h>
  4.  
  5. const byte internalLED = 13;
  6.  
  7. YunServer server;
  8.  
  9. void setup() {
  10. pinMode(internalLED, OUTPUT);
  11. digitalWrite(internalLED, HIGH); // Turn the led on to advise about bridge begin in progress
  12. Bridge.begin(); // Let's activate the Yun Bridge...
  13. ledBlink(150); // ...bridge activation done (user sees a blink)
  14. // server.listenOnLocalhost(); // Listen for incoming connection only from localhost (no one from the external network could connect)
  15. server.begin(); // Let's acrivate the Yun server...
  16. ledBlink(150); // ...server activation done (user sees a blink)
  17. }
  18.  
  19. void loop() {
  20. YunClient client = server.accept(); // Get clients coming from server
  21. if (client) // Is there a new client?
  22. {
  23. client.print(77); // Send a "77" to client (e.g. browser)
  24. client.stop(); // Close connection and free resources.
  25. ledBlink(500);
  26. }
  27. delay(50);
  28. }
  29.  
  30. void ledBlink(int delayTime) {
  31. digitalWrite(internalLED, HIGH); // Turn (or keep) the LED on
  32. delay(delayTime);
  33. digitalWrite(internalLED, LOW); // Turn (or keep) the LED off
  34. delay(delayTime);
  35. }
  36.  
  37. http://192.168.1.98/arduino/whatever
  38.  
  39. <!DOCTYPE html>
  40. <html>
  41. <head>
  42. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  43. <script>
  44. $.get("http://192.168.1.98/arduino/whatever", {}, function(data,status){
  45. alert("Data: " + data + "nStatus: " + status);
  46. });
  47. </script>
  48. </head>
  49. <body></body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement