将Unity Game与[Arduino +蓝牙模块(HC‐05)]或ESP32连接 [英] Connect Unity Game with [ Arduino + Bluetooth module (HC‐05) ] Or ESP32

查看:485
本文介绍了将Unity Game与[Arduino +蓝牙模块(HC‐05)]或ESP32连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 Bluetooth Unity 3D游戏 Arduino 之类的 Arduino 相连,为此我正在使用(HC-05)蓝牙模块.

为此,有一个名为 Arduino蓝牙插件的插件

此模块的图像可能也对您有用,因此您可以看到引脚图:

因此,在将arduino与我的笔记本电脑配对并使用命令收听传入的消息后

 <代码> $ cat/dev/rfcomm0 

我开始在控制台上看到输出:

因此,除了发送字符串之外,您还可以发送从Arduino输入中读取的所有内容,然后在C#端重新解析它.

我希望我能有所帮助;祝你好运!

I want to connect my Unity 3D Game with Micro-controller Like Arduino through Bluetooth and for that I'm using a (HC‐05) Bluetooth module.

And for that there is one plugin named Arduino Bluetooth Plugin Link in the asset Store. And Charge is 19$.

Is there any other way to do this by just using free functionality and Coding?

解决方案

You can definitely do it by coding it yourself.

I can't aid you with the C# part but I've written code to send data over the HC-06 module for arduino and communicated with an Android app via bluetooth and bluetooth low energy.

At the end of the day is very similar to Socket programming.

So for the C# part this user has a basic working C# BT communication example

And for the Arduino side I have used this sketch:


/**************************************************
 * 
 * Using the BUILT-IN Serial.
 * 
 * CONFIGURATION:
 * 
 *          ARDUINO NANO - HC-06
 *    YELLOW     TX         RX
 *    GREEN      RX         TX
 *    RED        3V3        VCC
 *    BLACK      GND        GND
 * 
 **************************************************/
void setup() {
  // Init the Built-In Serial.
  Serial.begin(9600);
}
void loop() {
  // Send the message
  Serial.println("MISSATGE PER UN LINUX!!!");

  delay(2000);
  
}

With this wiring:

This image of the module may also be useful to you, so you can see the pinout:

So after pairing the arduino with my laptop and listening to incomming messages by using the command

$ cat /dev/rfcomm0

I started seeing the output on my console:

So instead of sending a String you can send whatever you read from your Arduino inputs and then re-parse it on your C# side.

I hope I was helpful; Good luck!!!

这篇关于将Unity Game与[Arduino +蓝牙模块(HC‐05)]或ESP32连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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