Controlling Microcontroller
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
Hello,
This tutorial will show you how to connect to serial and write something in it.
Imports:
This will get name of port
Add this under Class
Writing:
-visioncr0
This tutorial will show you how to connect to serial and write something in it.
Imports:
Code: Select all
1. Listing all Serial(COM) ports to control (in code ComboBox)Imporst System.IO.Ports
This will get name of port
Code: Select all
Code below will add ports to control (ComboBox)
Dim ports As String() = SerialPort.GetPortNames()
Code: Select all
2. Connecting to port selected by userDim port As String
For Each port In ports
ComboBox1.Items.Add(port)
Next port
Add this under Class
Code: Select all
Code below will select serial port and open(connect) to itDim serialPort As New SerialPort
Code: Select all
Disconecting:Try
serialPort.PortName = ComboBox1.SelectedItem
serialPort.Open()
Catch ex as exception
End Try
Code: Select all
3. Writing/reading to serial portserialPort.close()
serialPort.dispose()
Writing:
Code: Select all
Reading:
serialPort.Write("something")
Code: Select all
That's allDim string As String = serialPort.ReadLine()
-visioncr0
Last edited by Filip on Sat Dec 24, 2011 6:37 pm, edited 1 time in total.
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
Hmm , I don't have any experience with this, but is a serial port a usb port ?
Axel wrote:Hmm , I don't have any experience with this, but is a serial port a usb port ?Yes, I'm using it to control my robot
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
Oh but can you explain more how to send power to the wires of a usb cable ?
Axel wrote:Oh but can you explain more how to send power to the wires of a usb cable ?Have you ever used HyperTerminal?
It is working this way:
I have a robot and this is a part of code witch is uploaded on flash memory onboard:
Code: Select all
So when I send code below to robot case 'w'://Move Forward
forward (leftspeed,rightspeed);
break;
Code: Select all
It moves forward serialPort.write("w")
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
Yes but you don't do the hard stuff right ? Because your robot processes it lol
Axel wrote:Yes but you don't do the hard stuff right ? Because your robot processes it lolOhhh really.. I changed title of topic lol
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
Not working for me. Combobox is empty and when I try msgbox(serialport.GetPortNames) - message box is not displaying! dunnno;
Maybe it's because of my notebook, but still...
Maybe it's because of my notebook, but still...
Ffenixw0rks wrote:Not working for me. Combobox is empty and when I try msgbox(serialport.GetPortNames) - message box is not displaying! dunnno;This won't list avalible ports but witch are in use. Are you sure something is connected to com(USB) port? Do you have drivers installed?
Maybe it's because of my notebook, but still...
Because it lists all ports to me..
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
Devices that was connected to computer: IPod and USB mouse.
Drivers for that devices are installed and working fine.
Drivers for that devices are installed and working fine.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023