{ TIME MACHINE WBA Consulting Andrew Williams (c)2013 Code is the remote for a setup that emulates a Time Machine Prop for a Church Christmas Kids Play. Simply reads a 4x4 keypad and transmits the key pressed over an xBee Portions from 4x4 Keypad Reader Demo by Beau Schwabe Schematic: xBee: DO = P0 DI = P1 The keypad connects directly to I/O 0-7. Looking at the Back of the 4x4 keypad... P7 P0 ││││││││ ┌─────── ││││││││ ───────┐ │ o ││││││││ o │ │ │ ~ ~ ~ ~ └────────────────────────┘ For the numbering scheme of the keypad (front view): Keypad Layout Keypad Encoding ┌────────────────────────┐ ┌────────────────────────┐ │ │ │ │ │ 1 2 3 A │ │ 4 3 2 1 │ │ │ │ │ │ 4 5 6 B │ │ 8 7 6 5 │ │ │ │ │ │ 7 8 9 C │ │ 12 11 10 9 │ │ │ │ │ │ * O # D │ │ 16 15 14 13 │ │ │ │ │ └────────────────────────┘ └────────────────────────┘ } CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ KP : "4x4 Keypad Reader" xb : "fullduplexserial" VAR word keypad PUB start | i xb.start(14, 15, 0, 9600) repeat keypad := >|KP.ReadKeyPad IF keypad <>0 CASE keypad 1 : i :=21 2 : i :=3 3 : i :=2 4 : i :=1 5 : i :=22 6 : i :=6 7 : i :=5 8 : i :=4 9 : i :=23 10 : i :=9 11 : i :=8 12 : i :=7 13 : i :=24 14 : i :=25 15 : i :=0 16 : i :=27 xb.tx("!") xb.dec(i) waitms(750) ' crude debounce PUB WAITMS(ms) 'wait time in milliseconds waitcnt(clkfreq / 1000 * mS + cnt) DAT {{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TERMS OF USE: MIT License │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ │is furnished to do so, subject to the following conditions: │ │ │ │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ }}