Author: eur.van.andel
Date: Mon Sep 1 14:23:41 2008
New Revision: 254
Modified:
trunk/unvalidated/sample/external/keyboard/keyboard_lcd.jal
Log:
improved keyboard_lcd.jal
Modified: trunk/unvalidated/sample/external/keyboard/keyboard_lcd.jal
==============================================================================
--- trunk/unvalidated/sample/external/keyboard/keyboard_lcd.jal (original)
+++ trunk/unvalidated/sample/external/keyboard/keyboard_lcd.jal Mon Sep 1
14:23:41 2008
@@ -1,6 +1,25 @@
--- prog.jal, to test LCD
+-- Title: Sample showing how to use the keyboard and the lcd library
+-- Author: Eru van Andel, [EMAIL PROTECTED] Copyright (c) 2008, all rights
reserved.
+-- 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.
+-- This 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. Do check your keyboard!
+-- The hardware used here are the Dwarf Boards: DB001, DB017 and a
home-brewed keyboard
+-- Check the keyboard.jal library for schematics.
+--
-include 16F877a
+
+include 16f877a -- can be any PIC, but
needs 8 pins for keyboard
+ -- 6 pins for LCD, 1 for
LED
pragma target clock 20_000_000 -- xtal frequency
pragma target OSC hs
@@ -11,7 +30,7 @@
var bit LED is pin_a0 -- LED to see proper PIC startup
-pin_a0_direction = output
+pin_a0_direction = output -- adding a LED is always a good idea
var bit RS is pin_b5 -- LCD command/data select.
var bit EN is pin_b4 -- LCD data trigger
@@ -20,11 +39,11 @@
include lcd -- LCD library
-var volatile byte keyscan is portd_low -- rows of keyboard
+var volatile byte keyscan is portd_low -- rows of keyboard
portd_low_direction = all_input
-var volatile byte keydrive is portd_high -- columns of keyboard
+var volatile byte keydrive is portd_high -- columns of keyboard
portd_high_direction = all_output
-include keyboard
+include keyboard -- check for schematics
for 4 loop
LED = on
@@ -45,11 +64,11 @@
var byte key
-forever loop -- loop forever
+forever loop -- loop forever
- lcdSetCursor(1, 0) -- second line, char 0
+ lcdsetcursor(1, 0) -- second line, first character
key = getkey()
- lcdWrthexchar(key)
+ lcdwrthexchar(key)
for 10 loop
delay100mus(200)
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
-~----------~----~----~----~------~----~------~--~---