house_ico_png.png

El código fuente en Visual Basic:

 

 

DECLARACIONES

 

Option Explicit

Dim Led As Byte

Dim Control As Boolean

Dim bRetVal As Boolean, bit As Byte

Private Declare Sub PortOut Lib “IO.DLL” (ByVal Port As Integer, ByVal Data As Byte)

Private Declare Sub PortWordOut Lib “IO.DLL” (ByVal Port As Integer, ByVal Data As Integer)

Private Declare Sub PortDWordOut Lib “IO.DLL” (ByVal Port As Integer, ByVal Data As Long)

Private Declare Function PortIn Lib “IO.DLL” (ByVal Port As Integer) As Byte

Private Declare Function PortWordIn Lib “IO.DLL” (ByVal Port As Integer) As Integer

Private Declare Function PortDWordIn Lib “IO.DLL” (ByVal Port As Integer) As Long

Private Declare Sub SetPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal bit As Byte)

Private Declare Sub ClrPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal bit As Byte)

Private Declare Sub NotPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal bit As Byte)

Private Declare Function GetPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal bit As Byte) As Boolean

Private Declare Function RightPortShift Lib “IO.DLL” (ByVal Port As Integer, ByVal Val As Boolean) As Boolean

Private Declare Function LeftPortShift Lib “IO.DLL” (ByVal Port As Integer, ByVal Val As Boolean) As Boolean

Private Declare Function IsDriverInstalled Lib “IO.DLL” () As Boolean

 

FORMULARIO DE CARGA

 

Private Sub Form_Load()

Frame1.Enabled = False

Text1.Text = 0

PortOut &H378, 0

For Led = 0 To 7

Led1(Led).Visible = False

LedE1(Led).Visible = False

Next Led

Control = False

End Sub

 

FORMULARIO DE SALIDA

 

Private Sub Form_Unload(Cancel As Integer)

PortOut &H378, 0

End Sub

 

 

 

FRAME 2

frame2_png.pngbotonactivar_png.png

 

Private Sub BotonActivar_Click()

If Control = False Then

LedActivar(1).Visible = True

LedActivar(0).Visible = False

Control = True

Frame1.Enabled = True

Else

LedActivar(0).Visible = True

LedActivar(1).Visible = False

Control = False

Frame1.Enabled = False

End If

End Sub

 

Private Sub BotonApagarGeneral_Click()

apagar_general_png.png

Text1.Text = 0

PortOut &H378, 0

For Led = 0 To 7

Led1(Led).Visible = False

 

 

 

 

 

 

 

 

Led0(Led).Visible = True

Next Led

End Sub

 

salir_png.png

 

 

 

Private Sub BotonSalir_Click()

PortOut &H378, 0

End

End Sub

 

 

 

 

 

 

 

FRAME 1

1_png.png

Private Sub Pin2_Click()

‘Verifica el estado del bit 0

bRetVal = GetPortBit(&H378, 0)

Select Case bRetVal

Case Is = False

‘Pone el bit 0 a nivel 1

SetPortBit &H378, 0

Text1.Text = Val(Text1.Text) + 1

Led1(0).Visible = True

Led0(0).Visible = False

Case Is = True

‘Pone el bit 0 nivel 0

NotPortBit &H378, 0

Text1.Text = Val(Text1.Text) – 1

Led1(0).Visible = False

Led0(0).Visible = True

End Select

End Sub

 

 

 

Private Sub Pin3_Click()

‘Verifica el estado del bit 1

bRetVal = GetPortBit(&H378, 1)

Select Case bRetVal

Case Is = False

‘Pone el bit 1 a nivel 1

SetPortBit &H378, 1

Text1.Text = Val(Text1.Text) + 2

Led1(1).Visible = True

Led0(1).Visible = False

Case Is = True

‘Pone el bit 1 a nivel 0

NotPortBit &H378, 1

Text1.Text = Val(Text1.Text) – 2

Led1(1).Visible = False

Led0(1).Visible = True

End Select

End Sub

 

 

Private Sub Pin4_Click()

‘Verifica el estado del bit 2

bRetVal = GetPortBit(&H378, 2)

Select Case bRetVal

Case Is = False

‘Pone el bit 2 a nivel 1

SetPortBit &H378, 2

Text1.Text = Val(Text1.Text) + 4

Led1(2).Visible = True

Led0(2).Visible = False

Case Is = True

‘Pone el bit 2 a nivel 0

NotPortBit &H378, 2

Text1.Text = Val(Text1.Text) – 4

Led1(2).Visible = False

Led0(2).Visible = True

End Select

End Sub

 

Private Sub Pin5_Click()

‘Verifica el estado del bit 3

bRetVal = GetPortBit(&H378, 3)

Select Case bRetVal

Case Is = False

‘Pone el bit 3 a nivel 1

SetPortBit &H378, 3

Text1.Text = Val(Text1.Text) + 8

Led1(3).Visible = True

Led0(3).Visible = False

Case Is = True

‘Pone el bit 3 a nivel 0

NotPortBit &H378, 3

Text1.Text = Val(Text1.Text) – 8

Led1(3).Visible = False

Led0(3).Visible = True

End Select

End Sub

 

Private Sub Pin6_Click()

‘Verifica el estado del bit 4

bRetVal = GetPortBit(&H378, 4)

Select Case bRetVal

Case Is = False

‘Pone la línea 4 a nivel 1

SetPortBit &H378, 4

Text1.Text = Val(Text1.Text) + 16

Led1(4).Visible = True

Led0(4).Visible = False

Case Is = True

‘Pone el bit 4 a nivel 0

NotPortBit &H378, 4

Text1.Text = Val(Text1.Text) – 16

Led1(4).Visible = False

Led0(4).Visible = True

End Select

End Sub

 

Private Sub Pin7_Click()

‘Verifica el estado del bit 5

bRetVal = GetPortBit(&H378, 5)

Select Case bRetVal

Case Is = False

‘Pone el bit 5 a nivel 1

SetPortBit &H378, 5

Text1.Text = Val(Text1.Text) + 32

Led1(5).Visible = True

Led0(5).Visible = False

Case Is = True

‘Pone el bit 5 a nivel 0

NotPortBit &H378, 5

Text1.Text = Val(Text1.Text) – 32

Led1(5).Visible = False

Led0(5).Visible = True

End Select

End Sub

 

Private Sub Pin8_Click()

‘Verifica el estado del bit 6

bRetVal = GetPortBit(&H378, 6)

Select Case bRetVal

Case Is = False

‘Pone el bit 6 a nivel 1

SetPortBit &H378, 6

Text1.Text = Val(Text1.Text) + 64

Led1(6).Visible = True

Led0(6).Visible = False

Case Is = True

‘Pone el bit 6 a nivel 0

NotPortBit &H378, 6

Text1.Text = Val(Text1.Text) – 64

Led1(6).Visible = False

Led0(6).Visible = True

End Select

End Sub

 

Private Sub Pin9_Click()

‘Verifica el estado del bit 7

bRetVal = GetPortBit(&H378, 7)

Select Case bRetVal

Case Is = False

‘Pone el bit 7 a nivel 1

SetPortBit &H378, 7

Text1.Text = Val(Text1.Text) + 128

Led1(7).Visible = True

Led0(7).Visible = False

Case Is = True

‘Pone el bit 7 a nivel 0

NotPortBit &H378, 7

Text1.Text = Val(Text1.Text) – 128

Led1(7).Visible = False

Led0(7).Visible = True

End Select

End Sub

 

https://japerfer.wordpress.com