Author: eur.van.andel
Date: Fri Oct 31 15:11:01 2008
New Revision: 511

Added:
    trunk/unvalidated/sample/by_device/16f876a/keyboard_lcd.jal

Log:
keyboard_lcd for 16f876a, with re-use of LCD nibble for keyboard drive


Added: trunk/unvalidated/sample/by_device/16f876a/keyboard_lcd.jal
==============================================================================
--- (empty file)
+++ trunk/unvalidated/sample/by_device/16f876a/keyboard_lcd.jal Fri Oct 31  
15:11:01 2008
@@ -0,0 +1,74 @@
+-- Title: Sample showing how to use the keyboard and the lcd library
+-- Author: Eur van Andel, [EMAIL PROTECTED] Copyright (c) 2008.
+-- Adapted-by:
+-- Compiler: >=2.4g
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license
+-- (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: this program shows how to use the keyboard library.
+-- The librar has only one function: getkey(). This function returns 0..15,
+-- depending on the key pressed on a 4x4 keyboard. It returns 16 is no key  
is
+-- pressed.
+-- The keyboard library assumes 8 pins are used, 4 rows and 4 columns
+-- four are output, four input.
+-- Most keyboards have around 300 ohm resistance, so nothing fries if more  
keys
+-- are pressed, or if the direction of the pins is set wrong.
+-- Check your keybaord for resistance when a key is pressed.
+-- In this example, the datanibble of the LCD screen is re-used.
+-- Wire the PIC pins with diodes to the keyboard so you don't fry the pins.
+-- Use 10k pulldowns for the input port
+--s
+
+include 16f876a                     -- can be any PIC,
+                                    -- but should have 8 pins for keyboard
+                                    -- and 6 pins for LCD
+pragma target clock 20_000_000      -- xtal frequency
+pragma target OSC        hs
+pragma target   LVP disabled
+pragma target   WDT disabled
+
+enable_digital_io()
+
+-- ---------------------------- LIBRARIES -----------------------------
+
+const byte  LCD_ROWS = 4
+const byte  LCD_CHARS = 20
+var   bit   LCD_RS           is pin_b5       -- LCD command/data select.
+var   bit   LCD_EN           is pin_b4       -- LCD data trigger
+var   byte  LCD_dataport     is portb_low    -- LCD data nibble
+portb_direction              = all_output    -- LCD data is portb_low
+include lcd_hd44780_4                        -- LCD library with 4 data  
lines
+lcd_init()
+
+include print
+
+var volatile byte keyscan  is portc_low      -- rows of keyboard
+portc_low_direction        = all_input
+var volatile byte keydrive is portb_low      -- columns of keyboard, also  
LCD
+                                             -- data, already output
+include keyboard
+
+-- -------------------------- PROGRAM START----------------------------
+
+lcd_clearscreen()
+lcd_setcursor(0,0)
+const byte str1[] = "sample keyboard & LCD"
+print_string(lcd, str1)
+
+var byte key
+
+forever loop
+   lcd_setcursor(1, 0)              -- second line
+   key = getkey()
+   print_byte_hex(lcd, key)
+
+   delay_100ms(2)
+end loop
+
+
+
+
+
+

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to