0% found this document useful (0 votes)
113 views24 pages

Electrical Appliace Via I.R Remote Control

This document contains code for programming in visual basic to control electrical appliances via an infrared remote control. The code defines variables and subroutines for receiving infrared signals from the remote, decoding the received signals, and controlling appliances by setting switch values. It also includes code for enabling/disabling different control modes like remote control, voice control and PC control.

Uploaded by

Akash Singh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views24 pages

Electrical Appliace Via I.R Remote Control

This document contains code for programming in visual basic to control electrical appliances via an infrared remote control. The code defines variables and subroutines for receiving infrared signals from the remote, decoding the received signals, and controlling appliances by setting switch values. It also includes code for enabling/disabling different control modes like remote control, voice control and PC control.

Uploaded by

Akash Singh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

"Programming in visual basic :electrical appliance control via I.

R remote
Dim arr(9) As Integer Dim op, Y, c, os As String Dim ti, X, z, l As Integer Dim j As Integer

Private Sub Command1_Click(Index As Integer) Call extrct(Index) End Sub

Private Sub Command13_Click() If Command13.Caption = "Enable Remote Control" Then Command13.Caption = "Disable Remote Control" Command12.Enabled = False Command11.Enabled = False MSComm1.RThreshold = 1 Else Command13.Caption = "Enable Remote Control" Command12.Enabled = True Command11.Enabled = True MSComm1.RThreshold = 0 End If

End Sub

Private Sub Command11_Click()

If Command11.Caption = "Enable Voice Control" Then Command11.Caption = "Disable Voice Control" Command12.Enabled = False Command13.Enabled = False SR1.Activate Else Command11.Caption = "Enable Voice Control" Command12.Enabled = True Command13.Enabled = True SR1.Deactivate End If

End Sub

Private Sub Command12_Click()

If Command12.Caption = "Enable PC Control" Then Command12.Caption = "Disable PC Control" Command13.Enabled = False Command11.Enabled = False

Else Command12.Caption = "Enable PC Control" Command13.Enabled = True Command11.Enabled = True End If End Sub

Private Sub Command14_Click() End End Sub

Private Sub MSComm1_OnComm() If MSComm1.CommEvent = comEvReceive Then c = MSComm1.Input l = Val(c) If arr(l) = 0 Then Option1(2 * l).Value = True arr(l) = 1 Else Option1(2 * l + 1).Value = True arr(l) = 0 End If extrct (l) End If

End Sub

Private Sub Option1_Click(Index As Integer) If Index Mod 2 = 0 Then X = Index / 2 Else X = (Index - 1) / 2 End If If Command12.Caption = "Disable PC Control" Then Call extrct(X) End If End Sub

Private Sub SR1_PhraseFinish(ByVal flags As Long, ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, ByVal endlo As Long, ByVal Phrase As String, ByVal parsed As String, ByVal results As Long) For i = 0 To 9 If Label1(i).Caption + " on" = Phrase Then arr(i) = 1 Option1(2 * i).Value = True Call extrct(i) ElseIf Label1(i).Caption + " close" = Phrase Then arr(i) = 0 Option1(2 * i + 1).Value = True

Call extrct(i) End If Next End Sub

Private Sub Form_Load() Dim gr As String

For i = 0 To 9 arr(i) = 0 Next

MSComm1.PortOpen = True 'Values for voice control gr = "" For i = 0 To 9 gr = gr + "<start>= " & Label1(i).Caption & " on" & vbCrLf & "<start>= " & Label1(i).Caption & " close" & vbCrLf Next SR1.GrammarFromString "[Grammar]" & vbCrLf & _ "type=cfg" & vbCrLf & _ "[<start>]" & gr End Sub

Private Sub extrct(X) If (Option1(2 * X).Value = True) Then op = Trim(Str(X)) + "N" arr(X) = 1 Shape1(X).BackColor = &HFF& Else op = Trim(Str(X)) + "F" arr(X) = 0 Shape1(X).BackColor = &HC0C0C0 End If ti = 0 Timer1.Enabled = True End Sub

Private Sub Timer1_Timer() If ti = 0 Then MSComm1.Output = Mid(op, 1, 1) ti = 1 Text1.Text = Mid(op, 1, 1) ElseIf ti = 1 Then MSComm1.Output = Mid(op, 2, 1) Timer1.Enabled = False Text1.Text = Text1.Text + Mid(op, 2, 1) End If

End Sub

PROGRAM CODE OF THE PROJECT. ;/***************************************************************** ***** ;* Phillips RC5 Decoding

VAR1 equ 07h TEMP equ 10H COUNT equ 11H ADDR equ 12H CMD equ 13H

;Temporary Variable ;Temp variable ;Count ;Device address ;Command

TEMP1 equ 14H FLIP bit 00H TOG bit 01H flag0 bit 04H svd1 equ 15h svd2 equ 16h IR equ P3.3

;Temporary Variable 1 ;Flip bit ;Temp bit for flip

;IR Receiver connected to this pin ;Switch 1 connected here ;Switch 2 connected here ;Switch 3 connected here ;Switch 4 connected here ;Switch 5 connected here ;Switch 6 connected here ;Switch 7 connected here ;Switch 8 connected here

SW1 equ P0.0 SW2 equ P0.1 SW3 equ P0.2 SW4 equ P0.3 SW5 equ P0.4 SW6 equ P0.5 SW7 equ P0.6 SW8 equ P0.7

SW9 equ P2.7 SW0 equ P2.6

;Switch 9 connected here ;Switch 0 connected here

org 0000h ljmp clrram1 org 0003h reti org 000bh reti org 0013h reti org 001bh reti

org 0023h ljmp sir_sl reti sir_sl: push psw push acc clr jnb mov clr ri a,sbuf es ri,$ a,sbuf

mov clr mov ri

svd2,a

cjne a,#'n',sir_nxt1 sir_nxt1:

cjne a,#'N',sir_nxt2 sir_nxt2: cjne a,#'f',sir_nxt3 sir_nxt3: cjne a,#'F',sir_nxt4 sir_nxt4: mov a,svd1

cjne a,#'0',sir_nxt5 mov sir_nxt5: cjne a,#'1',sir_nxt6 mov sir_nxt6: cjne a,#'2',sir_nxt7 mov C,flag0 SW1,C SW0,C

mov sir_nxt7:

SW2,C

cjne a,#'3',sir_nxt8 mov mov sir_nxt8: cjne a,#'4',sir_nxt9 mov mov sir_nxt9: cjne a,#'5',sir_nxt10 mov mov sir_nxt10: cjne a,#'6',sir_nxt11 C,flag0 SW5,C C,flag0 SW4,C C,flag0 SW3,C

mov mov sir_nxt11:

C,flag0 SW6,C

cjne a,#'7',sir_nxt12 mov mov sir_nxt12: cjne a,#'8',sir_nxt13 mov mov sir_nxt13: cjne a,#'9',sir_nxt14 mov mov sir_nxt14: C,flag0 SW9,C C,flag0 SW8,C C,flag0 SW7,C

reti clrram1: clr a mov r0,#7FH clrram: mov r0,a djnz r0,clrram mov sp,#50H mov TMOD,#20H mov SCON,#50H anl pcon,#7fh mov TH1,#0FBH mov TL1,#0FAH mov tcon,#00h mov ie,#90h ;Stack Pointer setup ;Serial port setup ;Receive enable ;Clearing Internal RAM

mov ip,#00h mov p0,#00h mov p1,#0ffh mov p2,#03fh mov p3,#0ffh clr TOG clr MODE setb TR1 setb es main: jb IR,main mov VAR1,#255 djnz VAR1,$ mov VAR1,#255 djnz VAR1,$ ;Wait for first bit ;3.024mS delay ;clear temp bit ;Set the default mode ;Start serial clock

mov VAR1,#255 djnz VAR1,$ mov VAR1,#255 djnz VAR1,$ mov VAR1,#255 djnz VAR1,$ mov VAR1,#100 djnz VAR1,$ mov c,IR mov FLIP,c clr A mov COUNT,#5 fadd: mov VAR1,#255 djnz VAR1,$ ;1.728mS delay for each bit ;Count for address ;Read Flip bit

mov VAR1,#255 djnz VAR1,$ mov VAR1,#255 djnz VAR1,$ mov VAR1,#4 djnz VAR1,$ mov c,IR djnz COUNT,fadd mov ADDR,A clr a mov COUNT,#6 fcmd: mov VAR1,#255 djnz VAR1,$ mov VAR1,#255 ;1.728mS Delay for each bit ;Count for Command ;Save the address

djnz VAR1,$ mov VAR1,#255 djnz VAR1,$ mov VAR1,#4 djnz VAR1,$ mov c,IR djnz COUNT,fcmd mov TEMP,CMD mov CMD,a mov a,ADDR cjne a,#00,nvalid mov a,TEMP cjne a,CMD,m_valid nvalid: ljmp main ;Check for valid command ;Save the old command ;Save the new command ;Cheack for valid address

m_valid: clr a mov c,FLIP mov TEMP1,a clr a mov c,TOG rlc a cjne a,TEMP1,m_valid1 sjmp nvalid m_valid1: mov c,FLIP mov TOG,c mov a,CMD clr c mskip:

cjne a,#01H,mskip1 mov a,#31H acall tx ljmp main

mskip1: cjne a,#02H,mskip2 mov a,#32H acall tx ljmp main

mskip2: cjne a,#03H,mskip3 mov a,#33H acall tx

ljmp main

mskip3: cjne a,#04H,mskip4 mov a,#34H acall tx ljmp main

mskip4: cjne a,#05H,mskip5 mov a,#35H acall tx ljmp main

mskip5:

cjne a,#06H,mskip6 mov a,#36H acall tx ljmp main

mskip6: cjne a,#07H,mskip7 mov a,#37H acall tx ljmp main

mskip7: cjne a,#08H,mskip8 mov a,#38H acall tx

ljmp main mskip8: cjne a,#09H,mskip9 mov a,#39H acall tx ljmp main mskip9: cjne a,#00H,mskip10 mov a,#30H acall tx mskip10: ljmp main

tx: mov sbuf,a

;Serial Transmit

jnb TI,$ clr TI nop ret

END

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy