; Lesson-013-IR-Receiver.bas #picaxe 20M2 ; Define the µProcessor IC Type ; Declare Constants & Variables symbol LED0 = B.4 ; B.0 = 0-bit of LED Display symbol LED2 = B.5 ; B.1 = 2-bit of LED Display symbol LED4 = B.6 ; B.2 = 4-bit of LED Display symbol LED8 = B.7 ; B.3 = 8-bit of LED Display ; symbol IRPin = B.0 symbol IRDat = b3 ; Read an IR Remote Control ; and Display the Binary Equivalent on the four LEDs ; BEGIN Main Body * * * * * * * * * * * * * * * * * * * * gosub OOOl pause 200 gosub OOlO pause 200 gosub OOll pause 200 gosub OlOl pause 200 gosub OllO pause 200 gosub Olll pause 200 gosub lOOO pause 200 gosub lOOl pause 200 gosub lOlO pause 200 gosub lOll pause 200 gosub llOO pause 200 gosub llOl pause 200 gosub lllO pause 200 gosub llll pause 200 do main: irin [1000,main],B.0,IRDat ; Wait for an IR signal debug IRDat if IRDat = 0 then gosub OOOl if IRDat = 1 then gosub OOlO if IRDat = 2 then gosub OOll if IRDat = 3 then gosub OlOO if IRDat = 4 then gosub OlOl if IRDat = 5 then gosub OllO if IRDat = 6 then gosub Olll if IRDat = 7 then gosub lOOO if IRDat = 8 then gosub lOOl if IRDat = 9 then gosub lOlO if IRDat = 10 then gosub lOll if IRDat = 11 then gosub llOO if IRDat = 12 then gosub llOl if IRDat = 13 then gosub lllO if IRDat = 14 then gosub llll loop ; END Main Body * * * * * * * * * * * * * * * * * * * ** end ; BEGIN Subroutines * * * * * * * * * * * * * * * * * * * OOOl: high LED0 ; PIN B.0 low LED2 ; PIN B.1 low LED4 ; PIN B.2 low LED8 ; PIN B.3 return OOlO: low LED0 ; PIN B.0 high LED2 ; PIN B.1 low LED4 ; PIN B.2 low LED8 ; PIN B.3 return OOll: high LED0 ; PIN B.0 high LED2 ; PIN B.1 low LED4 ; PIN B.2 low LED8 ; PIN B.3 return OlOO: low LED0 ; PIN B.0 low LED2 ; PIN B.1 high LED4 ; PIN B.2 low LED8 ; PIN B.3 return OlOl: high LED0 ; PIN B.0 low LED2 ; PIN B.1 high LED4 ; PIN B.2 low LED8 ; PIN B.3 return OllO: low LED0 ; PIN B.0 high LED2 ; PIN B.1 high LED4 ; PIN B.2 low LED8 ; PIN B.3 return Olll: high LED0 ; PIN B.0 high LED2 ; PIN B.1 high LED4 ; PIN B.2 low LED8 ; PIN B.3 return lOOO: low LED0 ; PIN B.0 low LED2 ; PIN B.1 low LED4 ; PIN B.2 high LED8 ; PIN B.3 return lOOl: high LED0 ; PIN B.0 low LED2 ; PIN B.1 low LED4 ; PIN B.2 high LED8 ; PIN B.3 return lOlO: low LED0 ; PIN B.0 high LED2 ; PIN B.1 low LED4 ; PIN B.2 high LED8 ; PIN B.3 return lOll: high LED0 ; PIN B.0 high LED2 ; PIN B.1 low LED4 ; PIN B.2 high LED8 ; PIN B.3 return llOO: low LED0 ; PIN B.0 low LED2 ; PIN B.1 high LED4 ; PIN B.2 high LED8 ; PIN B.3 return llOl: high LED0 ; PIN B.0 low LED2 ; PIN B.1 high LED4 ; PIN B.2 high LED8 ; PIN B.3 return lllO: low LED0 ; PIN B.0 high LED2 ; PIN B.1 high LED4 ; PIN B.2 high LED8 ; PIN B.3 return llll: high LED0 ; PIN B.0 high LED2 ; PIN B.1 high LED4 ; PIN B.2 high LED8 ; PIN B.3 return ; END Subroutines * * * * * * * * * * * * * * * * * * ** end