Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Re: Vb.Net DataReceived event doesn´t fire up on leonardo on: December 12, 2012, 02:44:28 am
 smiley-grin Great! smiley-wink

I'm glad it helped, I regret there is so little help about this issue.
2  Using Arduino / Interfacing w/ Software on the Computer / Re: Vb.Net DataReceived event doesn´t fire up on leonardo on: September 28, 2012, 01:53:10 am
Problem solved  smiley-cool, after some digging, i figured out the issue, properties SerialP.DtrEnable and SerialP.RtsEnable must both be set to True.

Thank you all anyway.

I will leave the this post, who knows, it can be useful to someone else.
3  Using Arduino / Interfacing w/ Software on the Computer / Vb.Net DataReceived event doesn´t fire up on leonardo on: September 27, 2012, 07:28:10 pm
Hello everyone, recently bought an Arduino Leonardo, however I am not able to receive data on VB.net side, I can send data to Arduino but can´t receive, DataReceived event doesn´t fire on VB.NET, can someone help me, already googled and I can´t see no reason why event DataReceived isn´t working.

Here´s my Vb code :

Code:
Public Class Form1

    Public WithEvents SerialP As System.IO.Ports.SerialPort


    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try
            'GetSerialPortNames()

            SerialP = New System.IO.Ports.SerialPort
            SerialP.BaudRate = 9600
            SerialP.PortName = "COM15"
            SerialP.DataBits = 8
            SerialP.ReadTimeout = 5000
            SerialP.WriteTimeout = 5000
            SerialP.Parity = IO.Ports.Parity.None
            SerialP.StopBits = IO.Ports.StopBits.One
            SerialP.Handshake = IO.Ports.Handshake.None
            'SerialP.Encoding = System.Text.Encoding.Default 'very important!
            SerialP.Encoding = System.Text.Encoding.UTF8

            SerialP.Open()
          
        Catch ex As Exception
            SerialP.Close()
        End Try


    End Sub

    Public Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialP.DataReceived
        MessageBox.Show("")
    End Sub

    Sub GetSerialPortNames()
        ' Show all available COM ports.
        For Each sp As String In My.Computer.Ports.SerialPortNames
            'cmboComm.Items.Add(sp)
        Next
    End Sub

    Private Sub SendToSerialP()
        If SerialP.IsOpen Then
            SerialP.Write("H")
        Else

            'SerialP.Write(txtSend.Text)
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SendToSerialP()
    End Sub

    Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        SerialP.Close()

    End Sub
  
End Class


And here is my Sketch :

Code:
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into
int counter;

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  establishContact();
  
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  counter = 0;
}

void loop() {

}


void establishContact() {
  while (Serial.available() <= 0) {
    Serial.print('A');   // send a capital A
    delay(300);
  }
}
Pages: [1]