I'm looking at Robin2's Serial Input Basics, and was trying to run some of his code. If I run it through the Arduino IDE, I can just click the serial monitor and begin inputting the things needed to run the program.
However, if I'm trying to use Visual Studio(VS), I can create a Arduino Project, load the code and the serial monitor works normally, but if I try and use a alternative monitor, I'm not sure where I need to be looking.
When I run my program, the Ardunio UNO shows it is receiving and transmitting, but I can't seem to find where it is showing it. I would assume it shold appear in the serial monitor where the Open and close commands occur, and the monitor shows such with the "Port opened/Port closed" remarks.
Where is my display going??? The only other thing I could think of is that I'd have to have the arduino not print, but send the array back to the GUI where I would then have to create labels for it to reappear, but that seems like the least likely solution.
For instance, if I load the receiving several character example into the VS IDE and load it, I can press the serial monitor and send "abcdefg", the arduino the RX and TX exactly as it should on the Serial Monitor.
If I create a different monitor(VS Windows Form), as below, the TX and RX behave exactly as if I used the IDE Serial Monitor except nothing shows on any of the Serial Monitors. What I tried was to have two separate instances of VS running, one for the IDE, one for the Serial Monitor, and then had the Serial Monitor display open for both instances, run the GUI to send the array, the lights light up, but neither Monitor displays any instance of print. Even the "Arduino is ready" is not displayed. Is there another window I'm supposed to be looking for?
I have attached a screenshot of the Serial Monitors in the attachments.
Robin2's Code to read char and display them
char receivedChar;
boolean newData = false;
void setup() {
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop() {
recvOneChar();
showNewData();
}
void recvOneChar() {
if (Serial.available() > 0) {
receivedChar = Serial.read();
newData = true;
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChar);
newData = false;
}
}
My VS GUI Serial Monitor replacement
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
SerialPort port;
public Form1()
{
InitializeComponent();
}
private void Arraysender_Click(object sender, EventArgs e)
{
//byte[] sendData = { 0x80, 0x0, 0x0, 0x00, 0x02, 0x20, 0x00, 0x03, 0x00, 0x05, 0x15, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3F, 0x04, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x40 };
char[] sendChar = { '°', 'q', 'w', 'e', 'r', 't', 'y' };
port = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
port.Open();
port.Write(sendChar,0,7);
port.Close();
}
}
}
Reference: port.Write information
null character for port.Write