sir,
I am a newbie in this language or any langguage for a fact , and i would like to learn how to put a LED and light it up on the printer port using a VB.net program. can anyone help me on this?
thank you and good day
rgds...
LED attached to printer port program using VB.net
Started by mario christian oquias, Apr 19 2008 10:30 PM
6 replies to this topic
#1
Posted 19 April 2008 - 10:30 PM
|
|
|
#2
Posted 20 April 2008 - 06:42 AM
What do you mean by the printer port? In any case, controlling external hardware is an advanced topic, and if you're still a newbie, I'd suggest you try something simpler (like showing an LED lighting up on the screen). What exactly is your "printer port"?
#3
Posted 21 April 2008 - 03:47 AM
I made an electrical circuit to show you how my circuit work. It is shown in the attached picture...
what i need now is the program...
i know the connections and i can comprehend the address when they say its binary or hex....
parallel Binary = 0, 1 --> 2 digit
Decimal = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 --> 10 digit
Hexadecimal = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F --> 16
port is what i mean when i said printer port....
now... the computer recognizes 0x378-0x37f
can i write that on my code to call DO-D7 pins?
for example if you click the link below he programmed it in c# so that is completely different from VB.net.....
CodeProject: I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port. Free source code and programming help
but the application is the same... this may prove to be a good learning experience for me if you guys can help me with this....
what i need now is the program...
i know the connections and i can comprehend the address when they say its binary or hex....
parallel Binary = 0, 1 --> 2 digit
Decimal = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 --> 10 digit
Hexadecimal = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F --> 16
port is what i mean when i said printer port....
now... the computer recognizes 0x378-0x37f
can i write that on my code to call DO-D7 pins?
for example if you click the link below he programmed it in c# so that is completely different from VB.net.....
CodeProject: I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port. Free source code and programming help
but the application is the same... this may prove to be a good learning experience for me if you guys can help me with this....
Attached Files
#5
Posted 21 April 2008 - 08:17 PM
so do i really need to learn C# before i learn VB.net? hmn... this may prove very tricky than i thought
#6
Posted 22 April 2008 - 10:01 AM
Nah, you don't have to learn C# as well. I learnt it out of preference, when I found I required more power than VB.NET could provide. Nevertheless, you don't need to learn it.
If you have a particular line of code you can't convert to VB, then post it and I'll give you the line in VB. I honestly can't be asked to go through the whole code project and convert it all, but it's really quite similar between them.
If you have a particular line of code you can't convert to VB, then post it and I'll give you the line in VB. I honestly can't be asked to go through the whole code project and convert it all, but it's really quite similar between them.
#7
Posted 07 December 2010 - 09:40 AM
I work with this all the time here the code i use. this is VB.net 2005 code it works in 2003 2005 2008 2010
I added the full project from when i was test this :c-cool:
add the DLL toy rhe system32 folder
I added the full project from when i was test this :c-cool:
add the DLL toy rhe system32 folder
Option Strict Off
Option Explicit On
Module InpOut32_Declarations
'Inp and Out declarations for port I/O using inpout32.dll.
Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Short) As Short
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Short, ByVal Value As Short)
End Module
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Out(&H378S, 2 + 1) 'Set (Data0 = 1 to 128, to on = 1 off = 0)write values of 0,1,2,4,8,16,32,64,128,
Dim Value1 As String 'String named Value1
Value1 = Inp(&H378S) 'Now Value1 has the values in 'data port'
'MessageBox.Show(Value1) 'A popup will indicate the current value written
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Value2 As String 'String named Value2
Value2 = Inp(&H379S) 'Now Value2 has the values in 'signal port'
'MessageBox.Show(Value2) 'A popup will indicate the current value written
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Out(&H378S, 2 = 0) 'Print '1' to D7-D0 or 255 in Decimal
Dim Value1 As String 'String named Value1
Value1 = Inp(&H378S) 'Now Value1 has the values in 'data port'
'MessageBox.Show(Value1) 'A popup will indicate the current value written
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Value2 As String 'String named Value2
Value2 = Inp(&H379S) 'Now Value2 has the values in 'signal port'
'MessageBox.Show(Value2) 'A popup will indicate the current value written
TextBox1.Text = Value2
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Out(&H378S, 2) 'Set (Data0 = 1 to 128, to on = 1 off = 0)write values of 0,1,2,4,8,16,32,64,128,
Dim Value1 As String 'String named Value1
Value1 = Inp(&H378S) 'Now Value1 has the values in 'data port'
'MessageBox.Show(Value1) 'A popup will indicate the current value written
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim Value2 As String 'String named Value2
Value2 = Inp(&H379S) 'Now Value2 has the values in 'signal port'
'MessageBox.Show(Value2) 'A popup will indicate the current value written
If Value2 = "112" Then
Timer2.Enabled = False
Timer3.Enabled = True
Out(&H378S, 0)
'MsgBox("2")
Else
'MsgBox("1")
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Timer2.Enabled = True
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Dim Value2 As String 'String named Value2
Value2 = Inp(&H379S) 'Now Value2 has the values in 'signal port'
'MessageBox.Show(Value2) 'A popup will indicate the current value written
If Value2 = "120" Then
Timer3.Enabled = False
Timer2.Enabled = True
Out(&H378S, 2 + 1)
' MsgBox("2")
Else
'MsgBox("1")
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Out(&H378S, 64)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Out(&H378S, 0)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Out(&H378S, 1)
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Out(&H378S, 2)
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Out(&H378S, 4)
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
Out(&H378S, 8)
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
Out(&H378S, 16)
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
Out(&H378S, 32)
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
Out(&H378S, 64)
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
Out(&H378S, 128)
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
Out(&H378S, 255)
End Sub
Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button25.Click
Out(&H378S, 1 + 128)
End Sub
Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button24.Click
Out(&H378S, 2 + 4)
End Sub
End Class
Attached Files
Edited by DarkDragon, 07 December 2010 - 10:18 AM.
Adding the needed Dll
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top












