I'm getting an error everytime I try connecting to the COM5 in my ELEGOO UNO R3.
I try sending data using a C# Form Framework through a button that prints 1 into the serial port.
Objective: The data is readed by an Arduino code that interpreates the data for later using it.
I try verifying by printing "one recieved"
Problem: Either says the port is busy or straight up doesn't connect.
Arduino code:
// VAR //
int ACT;
// SETUP //
void setup()
{
Serial.begin(9600);
Serial.println("Arduino Ready");
}
// PROGRAM //
void loop()
{
if(Serial.available() > 0)
{
ACT= Serial.parseInt();
switch(ACT)
{
case 1:
Serial.println("One recieved");
break;
case 2:
Serial.println("Two recieved");
break;
}
}
delay(50);
}
C# Form1.cs code:
using System;
using System.Windows.Forms;
using System.IO.Ports;
namespace gui2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
serialPort1.Open();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void uno_Click(object sender, EventArgs e)
{
serialPort1.Write("1");
}
private void dos_Click(object sender, EventArgs e)
{
serialPort1.Write("2");
}
}
}
I can run the arduino or the C# programs separately but when trying to have both so try to catch the sent information this error shows (Arduino opened first):
System.UnauthorizedAccessException: 'Se ha denegado el acceso al puerto 'COM5'.'
Or this (C# program opened first):
El Sketch usa 2090 bytes (6%) del espacio de almacenamiento de programa. El máximo es 32256 bytes.
Las variables Globales usan 228 bytes (11%) de la memoria dinámica, dejando 1820 bytes para las variables locales. El máximo es 2048 bytes.
avrdude: ser_open(): can't open device "\.\COM5": Acceso denegado.
Failed uploading: uploading error: exit status 1
2 posts - 2 participants