473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Receiving Data From Serial Port & Starting a Timer - Visual Basic Express

Alright. So I'm building a small timing system as a "beta" for a local racetrack. I know that the VB Timer is inaccurate .. But that's why it's a beta. I'm using Visual Basic Express 2010

I'm taking an infrared sensor, and connecting it to a microcontroller. The microcontroller will read the input of the sensor (whether it's broke or not) and then decide what it needs to do.

Here's how it's SUPPOSED to work together:

You choose how many laps of qualifying you would want to do on the VB program. 1 lap or 2 laps. The VB program will then send a string to the microcontroller saying whether it's 1 or 2 laps. Next, the microcontroller checks to make sure the infrared is not broke, and it's reflecting off of the reflector. If it is reflecting, the program will wait until the infrared beam is broke. Now it will send a string to the VB program. The VB program will decide what that string is supposed to mean. (Start or Stop the timer). The problem I'm having is getting the VB program to receive the data being sent, and doing something with it. Here is the code i'm using to send data to the microcontroller:
Expand|Select|Wrap|Line Numbers
  1. Private WithEvents serialPort As New IO.Ports.SerialPort
  2.  
  3.  
  4.  
  5. serialPort.Write("1") ' ThPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6. If serialPort.IsOpen Then
  7. serialPort.Close()
  8. End If
  9. Try
  10. With serialPort
  11. .PortName = "COM5"
  12. .BaudRate = 9600
  13. .Parity = IO.Ports.Parity.None
  14. .DataBits = 8
  15. .StopBits = IO.Ports.StopBits.One
  16. .Handshake = IO.Ports.Handshake.None
  17. End With
  18. serialPort.Open()
  19. Catch ex As Exception
  20. MsgBox(ex.ToString)
  21. End Try
  22.  
  23. End Sub
  24.  
  25. Private Sub OneLap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OneLap.Click
  26.  
  27. 'When you click OneLap it will show a bunch of labels, and other buttons.
  28.  
  29. PictureBox2.Visible = True
  30. Label1.Visible = False
  31. Button1.Visible = False
  32. Button2.Visible = False
  33. Button3.Visible = True
  34. OneThousandths.Visible = True
  35. OneHundredths.Visible = True
  36. OneTenths.Visible = True
  37. OneDP.Visible = True
  38. OneSeconds.Visible = True
  39. Button4.Visible = True
  40. Button6.Visible = True
  41. Label2.Visible = True
  42. Label15.Visible = True
  43. Label16.Visible = True
  44. CheckBox1.Visible = Truee microcontroller reads "1" as 1 Lap Qualifying
  45.  
  46. End Sub
This code above only shows what would happens when you click a button for 1 Lap Qualifying.

Here's what I need the VB Program to do:

When the Microcontroller sends a string of "1" it needs to start the timer. When it receives the string of "2" it needs to stop the timer.

(if it's two laps)

When the Microcontroller sends a string of "3" it needs to start the Lap One timer. When it Receives the string of "4" it needs to stop the Lap One timer and Start the Lap Two timer. When it receives the string "5" it needs to stop the Lap Two timer.

I am fairly new to this, so how would I do it??

Any help is appreciated!!

-Ryan
May 25 '12 #1
0 1750

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: lec | last post by:
Hi, I'm trying to write a program to read from the serial port & write whatever that is read to the X console (/dev/tty7). For X to recognize the characters sent, I believe you have to send...
1
by: MC | last post by:
Hi folks. Having a slight problem with ConfigurationManager in Visual Basic Express Edition 2005. Its claiming the Name ConfigurationManager is not declared. It works fine in Visual Web...
5
by: rolszyk | last post by:
I am trying to create a silent install for the free version of Visual Basic Express. Currently I am working on creating an msi, but it keeps failing to install the program on my virtual machine. I...
1
by: manivesa | last post by:
Hello does anybody knows how to set manufacturer property when publishing a project with visual basic express? Thanks
0
by: Errol Neal | last post by:
I'm trying to play around with VBA and Visual Basic 2005 Express. I thought I'd play around with the API for RTC so I installed the SDK for 1.2 and 1.3. I regestered the dll, but when i add it as a...
1
by: Faiz Faraj Adamo | last post by:
i am new in visual basic 5 and i read a book , but i found so many names of controls have differ from express edition and when i go to the help of express edition i do not find everything i need ,can...
6
by: | last post by:
Hi, I'm steel trying to read and update my XML file with Visual Basic Express but i am unable to find the right way to read my xml file and update it if neccessary... Here is my problem :...
2
by: dancer | last post by:
In Visual Basic 2005 Express Edition When I choose Console Application for the project, the source code page automatically comes up with: Module Module1 When I choose Windows Application, the...
3
by: =?Utf-8?B?Rmxhc2hwcm8=?= | last post by:
i have googled this question but cannot find an answer. i'm running windows vista and i'm using Visual Basic Express 2008. i know the build event button SHOULD be in under the compile tag but i...
1
by: jschraer | last post by:
Need help! I installed Visual Basic Express 2008 on a Windows Vista Premium machine with 2.4 GHZ and 2 gigabyte of RAM. I start VB Express and choose File|New|Windows Forms Application. VB...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.