RSS

IR RC5 4 device remote control

20 Jun

$regfile = “m16def.dat”
$crystal = 8000000

Config Pind.2 = Input
Config Rc5 = Pind.2 [ , Timer = 2]

Config Pinc.0 = Output
Config Pinc.1 = Output
Config Pinc.2 = Output
Config Pinc.3 = Output
Config Pind.7 = Output

Config Lcd = 16 * 2
Config Lcdbus = 4
Config Lcdmode = Port
Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portc.5 , Rs = Portc.4
Enable Interrupts

Dim Command As Byte
Dim Address As Byte

Reset Portc.0
Reset Portc.1
Reset Portc.2
Reset Portc.3
Reset Portd.7
Enable Interrupts
Cls
Lcd “<===Welcome====>”
Lowerline
Lcd ” Remote Control ”
Wait 2
Cls
Lcd “Waiting…”

Do
Getrc5(address , Command)
Command = Command And &B01111111
If Address = 0 Then
If Command = 1 Then
Toggle Portc.0
Cls
Lcd “Device 1 ”
Elseif Command = 2 Then
Toggle Portc.1
Cls
Lcd “Device 2 ”
Elseif Command = 3 Then
Toggle Portc.2
Cls
Lcd “Device 3 ”
Elseif Command = 4 Then
Toggle Portc.3
Cls
Lcd “Device 4 ”
Elseif Command = 12 Then
Reset Portc.0
Reset Portc.1
Reset Portc.2
Reset Portc.3
Cls
Lcd “All Device”
Lowerline
Lcd ”    Off”
Else
Cls
Lcd “Wrong Key…”
Portd.7 = 1
Waitms 500
Portd.7 = 0
Waitms 500
Portd.7 = 1
Waitms 500
Portd.7 = 0
End If
End If
Waitms 100

Loop

End

Advertisements
 
Leave a comment

Posted by on June 20, 2010 in AVR

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: