You are on page 1of 8

Parallel port

The diagram below shows the parallel port and what all of the pins do. For our current purposes, we only need pins 2-9 and pins 18-25.

positive side of a LED into pins 2-9 on your parallel port and the negative side of the LED into pins 1825.

Ok, as I stated above, Visual Basic doesnt provide any direct access to the parallel port. So, we will have to declare the functions that we will need to use from the INPOUT32.dll.

Declaration for parallel Port in VB6. Private Declare Function Inp Lib "inpout32.dll" _ Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Private Declare Sub Out Lib "inpout32.dll" _ Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)

2^8
Decimal #

2^7

2^6 64

2^5 32

2^4 16

2^3 8

2^2 4

2^1 2

2^0 1

0 128 * >255 will be overfl ow All turn Off LED 8 on

LED

LED 7 on

LED 6 on

LED 5 on

LED 4 on

LED 3 on

LED 2 on

LED 1 on

Private Sub cmdswitch1_Click() Out PortAddress, 1 only LED1 turns On End Sub

Private Sub cmdswitch6_Click() Out PortAddress, 32 End Sub only LED5 turns On

Private Sub cmdswitchd2_Click() Out PortAddress, 2 only LED2 turns On End Sub

Private Sub cmdswitch7_Click() Out PortAddress, 64 only LED6 turns On

Private Sub cmdswitch3_Click() Out PortAddress, 4 only LED3 turns On End Sub

End Sub

Private Sub cmdswitch8_Click()


Out PortAddress, 128
Private Sub cmdswitch4_Click() Out PortAddress, 8 only LED3 turns On End Sub

only LED7 turns On

End Sub

Private Sub cmdswitch9_Click()


Private Sub Command5_Click() Out PortAddress, 16 only LED4 turns On End Sub

Out PortAddress, 0 End Sub

all LED turn OFF

PROBLEM BASED LEARNING


Private Sub Form_Load() PortAddress = &H378 Dim PortAddress As String Private Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer Private Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer) End Sub Private Sub cmdswitch1_Click() Out PortAddress, 1 only LED1 turns On End Sub

Private Sub cmdswitch6_Click() Out PortAddress, 32 End Sub

only LED5 turns On

Private Sub cmdswitchd2_Click() Out PortAddress, 2 only LED2 turns On End Sub Private Sub cmdswitch3_Click() Out PortAddress, 4 only LED3 turns On End Sub Private Sub cmdswitch4_Click() Out PortAddress, 8 only LED3 turns On End Sub Private Sub Command5_Click() Out PortAddress, 16 only LED4 turns On End Sub

Private Sub cmdswitch7_Click() Out PortAddress, 64 only LED6 turns On End Sub

Private Sub cmdswitch8_Click() Out PortAddress, 128 only LED7 turns On End Sub

Private Sub cmdswitch9_Click() Out PortAddress, 0 all LED turn OFF End Sub

PROBLEM BASED LEARNING


Write a VB code to fulfill the problem below:
#Cmd button click 1 3 5 7 2,4,6,8 # LED turns ON 2 and 4 1 5 and 7 1,3,5 and 7 All

You might also like