Pages: [1]   Go Down
Author Topic: how to set output of Arduino to be inputted to VB.net  (Read 1148 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i want that output of the arduino to be inputted on an Programming language..VB.net to be exact..some say that is just using serial port..what will i code to send that output from arduino to vb.net..is it analog or digital that will be passed to vb.net?..

here is my code already..it will output high when the sensorvalue is less than 41

Code:

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;       // value output to the PWM (analog out)
void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue, DEC);
  delay(0);
 if(sensorValue > 41){
    digitalWrite(ledPin, LOW); 
} else {
    digitalWrite(ledPin, HIGH); 
}       
delay();
 
}


Instead of using LED to the output..i want to send it to computer and later be read to VB.net..is it possible?..

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49034
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/playground/Main/InterfacingWithSoftware
Most PC programming languages have a facility to read from/write to the serial port. Some are easier to use than others. C# is about as easy as it gets. Micro$oft even gives away a version of Visual Studio that can be used to develop C# applications.

The Arduino is on the other end of the serial port, using Serial.print(ln)()/write() and Serial.read() to write to and read from its end of the serial port.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/playground/Main/InterfacingWithSoftware
Most PC programming languages have a facility to read from/write to the serial port. Some are easier to use than others. C# is about as easy as it gets. Micro$oft even gives away a version of Visual Studio that can be used to develop C# applications.

The Arduino is on the other end of the serial port, using Serial.print(ln)()/write() and Serial.read() to write to and read from its end of the serial port.


i have an output(from arduino) that i want to communicate with the computer...

these are from 00000-11111 or 0 - 32 in hex data...can i send that to vb.net?..can you site a sample code..
Logged

South East England
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

He has given you the answer
the arduino uses the Serial Library not a pin

Code:
Serial.print("text");

but you will need to set u pthe serial first with a baud rate, etc first

then in VB/C# or anyother language with access to serial port, you just need to find the correct serial port, and listen on that for input
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8490
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

pangetadrian, I've posted code on one of your other threads.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This solution is not "invented" by me but a really good way to do it:


Imports System.IO.Ports
Imports System.Threading



Public Class Form1

    Dim WithEvents SerialPort As New IO.Ports.SerialPort

    Private Sub ConnectSerial()
        Try
            SerialPort.BaudRate = 9600
            SerialPort.PortName = "COM3"
            SerialPort.Open()
        Catch
            SerialPort.Close()
        End Try
    End Sub

    Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
        Dim str As String = SerialPort.ReadExisting()
        Invoke(myD1, str)

    End Sub

    Delegate Sub myMethodDelegate(ByVal [text] As String)
    Dim myD1 As New myMethodDelegate(AddressOf myShowStringMethod)

    Sub myShowStringMethod(ByVal myString As String)
        'display text to our textbox
        TextBox2.AppendText(myString)
    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        TextBox2.Text = ""
        If SerialPort.IsOpen Then
            SerialPort.Write("1-")
            TextBox1.Text = ""
        Else
            ConnectSerial()
            SerialPort.Write("1-")
            TextBox1.Text = ""
        End If

    End Sub
Logged

Pages: [1]   Go Up
Jump to: