Components and supplies
1
Arduino Yun
Project description
Code
Code snippet #1
arduino
Code snippet #1
arduino
Code snippet #2
arduino
Comments
Only logged in users can leave comments
Components and supplies
Arduino Yun
Project description
Code
Code snippet #1
arduino
1<!DOCTYPE HTML> 2<head> 3<title>Yun Messages</title> 4<script type="text/javascript" src="zepto.min.js"></script> 5</head> 6<body> 7<H1> Insert your message </H1> 8<form name="msgform" onSubmit="return sendMsg()"> 9<input type="text" name="msg"> 10<input type="submit" value="Yun it!" > 11</form> 12<script type="text/javascript"> 13 14function sendMsg() { 15$.get('/arduino/msg/' + document.msgform.msg.value + '/', 16 function(){ 17 alert("Success"); 18 } 19); 20return false; 21 22} 23</script> 24</body>
Code snippet #1
arduino
1<!DOCTYPE HTML> 2<head> 3<title>Yun Messages</title> 4<script type="text/javascript" src="zepto.min.js"></script> 5</head> 6<body> 7<H1> Insert your message </H1> 8<form name="msgform" onSubmit="return sendMsg()"> 9<input type="text" name="msg"> 10<input type="submit" value="Yun it!" > 11</form> 12<script type="text/javascript"> 13 14function sendMsg() { 15$.get('/arduino/msg/' + document.msgform.msg.value + '/', 16 function(){ 17 alert("Success"); 18 } 19); 20return false; 21 22} 23</script> 24</body>
Code snippet #2
arduino
1#include <Bridge.h> 2#include <YunServer.h> 3#include <YunClient.h> 4 5YunServer server; 6String msg; 7 8 9void setup () { 10 11 Serial.begin(9600); 12 Bridge.begin(); 13 server.listenOnLocalhost(); 14 server.begin(); 15 16 17} 18 19void loop () { 20 //*********Read new message from the client************** 21 YunClient client = server.accept(); //check new clients 22 23 if(client) { 24 String command = client.readStringUntil('/'); //read the incoming data 25 if (command == "msg") { 26 msg = client.readStringUntil('/'); // read the incoming data 27 } 28 client.stop(); 29 } 30 31} 32 33
Comments
Only logged in users can leave comments