Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21990

Automatic power with parrallel port when clock hits a certain time

$
0
0
I am trying to create clock program that when the clock strikes a certain it will give power through the parrallel port. But I am having a hard time getting this working.. I posted my code below so far. Any pointers would be greatly appreicated. Thanks

Code:

' Parallel port monitor
' PortAddress is the address of the data register.
' PortAddress+1 is the feedback register.
' PortAddress+2 is the control register.
Dim PortAddress As Integer
' Flag to keep track of self-inflicted events.
Dim Self As Boolean

Public Sub Buzz()
If alarm = Str$(Time) Then
Text1 = "Buzz"
MMControl1.Command = "Poll_Timer"
End If
End Sub

Private Sub Command1_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text1 = alarm
Command1.Caption = "Alarm Set"
Command1.BackColor = &H0&
End Sub

Private Sub Command10_Click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text10 = alarm
Command10.Caption = "Alarm Set"
Command10.BackColor = &HFF
End Sub

Private Sub Command11_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text11 = alarm
Command11.Caption = "Alarm Set"
Command11.BackColor = &HFF
End Sub

Private Sub Command2_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text2 = alarm
Command2.Caption = "Alarm Set"
Command2.BackColor = &HFF
End Sub

Private Sub Command3_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text3 = alarm
Command3.Caption = "Alarm Set"
Command3.BackColor = &HFF
End Sub

Private Sub Command4_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text4 = alarm
Command4.Caption = "Alarm Set"
Command4.BackColor = &HFF
End Sub

Private Sub Command5_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text5 = alarm
Command5.Caption = "Alarm Set"
Command5.BackColor = &HFF
End Sub

Private Sub Command6_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text6 = alarm
Command6.Caption = "Alarm Set"
Command6.BackColor = &HFF
End Sub

Private Sub Command7_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text7 = alarm
Command7.Caption = "Alarm Set"
Command7.BackColor = &HFF
End Sub

Private Sub Command8_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text8 = alarm
Command8.Caption = "Alarm Set"
Command8.BackColor = &HFF
End Sub

Private Sub Command9_click()
alarm = InputBox("set Alaram Time", "Alarm Set", Time)
Text9 = alarm
Command9.Caption = "Alarm Set"
Command9.BackColor = &HFF
End Sub

' Change one bit in the control register.
Private Sub ControlCheck_Click(Index As Integer)
  If Self Then Exit Sub
  Dim register As Byte
  register = Inp(PortAddress + 2)
  register = register Xor 2 ^ Index
  Out PortAddress + 2, register
End Sub

' Change one bit in the data register.
Private Sub DataCheck_Click(Index As Integer)
  If Self Then Exit Sub
  If ControlCheck(5).Value = 1 Then Beep
  Dim register As Byte
  register = Inp(PortAddress)
  register = register Xor 2 ^ Index
  Out PortAddress, register
End Sub
' Other Junnnnnnnnnnnkkkkkk
Public Sub wakeup()
If alarm = Str$(Time) Then
If ControlCheck(5).Value = 1 Then Beep
  Dim register As Byte
  register = Inp(PortAddress)
  register = register Xor 2 ^ Index
  Out PortAddress, register
End If
End Sub

' Changes to the feedback register are impossible.
Private Sub FeedCheck_Click(Index As Integer)
  If Not Self Then Beep
End Sub

Private Sub MMControl1_Done(NotifyCode As Integer)
Command1.Caption = "Set Alarm"
Command1.BackColor = &HFFFF&
Text1 = ""
MMControl1.Command = "Close"
MMControl1.Command = "Open"
End Sub

Private Sub Timer1_Timer()
If Label13.Caption <> CStr(Time) Then
Label13.Caption = Time
End If
End Sub

' Scan all three registers and update the display.
' Repeat ten times a second.
Private Sub Poll_Timer()
  Dim register As Byte
  Dim i As Byte
  Self = True ' avoid recursive changes
 
  ' Read control register
  register = Inp(PortAddress + 2)
  For i = 0 To 5
    If register And 2 ^ i Then
      ControlCheck(i).Value = 1
    Else
      ControlCheck(i).Value = 0
    End If
  Next i
  Self = False
End Sub

' Change the parallel port.
Private Sub PortSelect_Click(Index As Integer)
  Select Case Index
  Case 0
    PortAddress = &H3BC
  Case 1
    PortAddress = &H378
  Case 2
    PortAddress = &H278
  End Select
End Sub

Private Sub Timer2_Timer()
Timer2.Interval = 1
End Sub



and



Code:



'Inp and Out declarations for direct port I/O
'in 32-bit Visual Basic 4+ programs.

Public Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)


Viewing all articles
Browse latest Browse all 21990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>