Bascom - Remote Control TV untuk kontrol lampu rumah




$regfile = "reg51.dat"
$crystal = 11059200

Dim C11 As Integer
Dim C12 As Integer
Dim C20 As Integer
Dim Z As Byte
Dim Y As Byte
Dim X As Bit
Config Timer0 = Counter0 , Gate = Internal , Mode = 1


Do                                                            'set up a loop

Bitwait P2.7 , Reset
   Counter0 = 0                                               'clear counter
   Start Counter0


Bitwait P2.7 , Set
Bitwait P2.7 , Reset
   C11 = Counter0
   Counter0 = 0                                            
   Start Counter0


If C11 > 9000 Then


Z = 0
Y = 0

For C20 = 0 To 26
Call Ambil
Call Masukan
If Y = 29 Then
   'Print "Dapet"
   C20 = 26
End If
Next



'------------

If Z = 252 Then
   If P2.0 = 0 Then
      P2.0 = 1
   Else
      P2.0 = 0
   End If
End If

If Z = 236 Then
   If P2.1 = 0 Then
      P2.1 = 1
   Else
      P2.1 = 0
   End If
End If


If Z = 244 Then
   If P2.2 = 0 Then
      P2.2 = 1
   Else
      P2.2 = 0
   End If
End If


If Z = 228 Then
   If P2.3 = 0 Then
      P2.3 = 1
   Else
      P2.3 = 0
   End If
End If


'Print Z

End If
Loop

End

Sub Masukan()
Y.7 = Y.6
Y.6 = Y.5
Y.5 = Y.4
Y.4 = Y.3
Y.3 = Y.2
Y.2 = Y.1
Y.1 = Y.0
Y.0 = Z.7
Z.7 = Z.6
Z.6 = Z.5
Z.5 = Z.4
Z.4 = Z.3
Z.3 = Z.2
Z.2 = Z.1
Z.1 = Z.0
Z.0 = X
End Sub




Sub Ambil()
Bitwait P2.7 , Set
Bitwait P2.7 , Reset
   C11 = Counter0
Counter0 = 0
Start Counter0

If C11 > 1500 Then
   X = 1
   Else
   X = 0
End If
End Sub

Postingan populer dari blog ini

LCD 2x16 via ESP32

Perencanaan awal ESP32 S3 testing

winsocket vb.net