I want to check my serial monitor when my unity is running.
But my unity code is sending a message to same port with arduino,
Error message comes out.
Are there anyway I can check serial monitor during unity is running?
Your topic was MOVED to its current forum category as it is more suitable than the original as it is not a question about installation of the IDE
If you want to use the Serial monitor in your sketch then you should not use the same serial pins to communicate with another device. You need to use a second serial port instead
Which Arduino board are you using and what is a "unity" ?
Can you explain that a bit more? I have no idea what you want to do.
Unity is game engine program, And thanks for moving my question!
From Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO.Ports;
public class NewBehaviourScript : MonoBehaviour
{
SerialPort data_stream = new SerialPort("COM5", 9600);
// Start is called before the first frame update
void Start()
{
data_stream.Open();
}
// Update is called once per frame
void Update()
{
string h = "hello";
byte[] bytes2 = Encoding.UTF8.GetBytes(h);
data_stream.Write(bytes2, 0, bytes2.Length);
}
private void OnApplicationQuit()
{
data_stream.Close();
}
}
By this code i send hello to arduino as bytes.
And I want to check arduino serial monitor that bytes is come correctly while "update statement" is running.
Hello,
you still didn't answer all of our questions.
Where is the Unity program running? On the same PC as the serial monitor? Which Arduino board are you using and how is everything connected? As @UKHeliBob already stated, you cannot use the same port for serial monitor and your Unity program.
Yes. I use same computer, same port so i get "port is busy error"
So I want to know other way I can run both 'unity', 'arduino serial monitor'.
(ex, use two computer or else)
I am using arduino nano 33 iot board just for serial communication
If only you told us that earlier
On the Nano 33 IOT pins 0 and 1 are Serial1 not Serial. The Serial monitor and uploading code to the PC uses the Serial interface, not pins 0 and 1
You should be able to interact with an external system using a serial link on Serial1 using pins 0 and 1
You have to use two different (virtual) serial ports, and you need an Arduino with two serial interfaces. I don't know the nano 33 iot, but I think it has a native USB interface and a separate serial interface (RX/TX). So you only need a serialToUSB converter to connect the arduino to the Unity port and the serial monitor port.
Too late ![]()
It is never too late and when you have invested time to type a post you may just as well post it even if it duplicates some or all of a reply that has been posted in the meantime and a different slant on the same solution is no bad thing
@MicroBahner @UKHeliBob
Sorry for replying too late.
Thanks for you guys help despite the inconvenience I made
Is your problem solved ?
Yes thanks
I will find for how to use serial1(sending data from PC to arduino) , and serial(for seiral monitor) together.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.