将数据从Arduino发送到ASP.NET [英] Send Data From Arduino to ASP.NET

查看:91
本文介绍了将数据从Arduino发送到ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,

我在asp.net中从c#到javascript的可靠调用有问题。

如何执行Arduino uno的实时检索没有wifi shileld通过C#然后传递给将在网络上显示的javascript。其中传输的数据值得连续0和1。



例如:



Arduino代码:

void setup(){

/ /初始化数字引脚作为输出。



}



void loop(){

Serial.write(1);

delay(1000 );

Serial.write(0);

延迟(1000);

}

< br $>


C#代码

public String msg;

public void DataReceivedHandler(object sender,SerialDataReceivedEventArgs e){

SerialPort sp =(SerialPort)发送者;

indata string = sp.ReadExisting();



msg = indata;





}



Javascript code

SaySomethingToUnity函数( ){

a =< %= msg%>

alert(a);

u.getUnity()。 SendMessage(主要摄像头,note_c,a);



}

Please help me ,
I have a problem regarding valiable calling from c # to javascript in asp.net .
how to perform real-time retrieval of Arduino uno without wifi shileld through C # then passed to the javascript that will be displayed on the web . where the transmitted data is worth " 0 " and " 1 " continuously.

for example :

Arduino code :
void setup ( ) {
  / / Initialize the digital pin as an output .
      
}

void loop ( ) {
  Serial.write ( " 1 " ) ;
  delay (1000 ) ;
 Serial.write ( " 0 " ) ;
  delay (1000 ) ;
}


C # Code
 public String msg ;
 public void DataReceivedHandler ( object sender , SerialDataReceivedEventArgs e ) {
            SerialPort sp = ( SerialPort ) sender ;
            indata string = sp.ReadExisting ( ) ;

            msg = indata ;

           
        }

Javascript code
 SaySomethingToUnity function ( ) {
                 a = < % = msg % >
                 alert ( a) ;
                 u.getUnity ( ) . SendMessage ( " Main Camera " , " note_c " , a) ;
                      
             }

推荐答案

这篇关于将数据从Arduino发送到ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆