Author: robhamerling
Date: Sat Oct 25 13:16:11 2008
New Revision: 473

Added:
    trunk/unvalidated/sample/by_device/16f88/hello_world_lcd.jal

Log:
Hello world sample with for 16f88



Added: trunk/unvalidated/sample/by_device/16f88/hello_world_lcd.jal
==============================================================================
--- (empty file)
+++ trunk/unvalidated/sample/by_device/16f88/hello_world_lcd.jal        Sat Oct 
25  
13:16:11 2008
@@ -0,0 +1,75 @@
+-- Title: Hello world with an LCD
+-- Author: Eur Van Andel, Copyright (c) 2008, all rights reserved.
+-- Adapted-by: Rob Hamerling
+-- 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 sample shows how to setup an LCD and writes
+-- "Hello World" to the first line, using a string and the print library.
+-- Line 3 and line 4 are used as well, but will work properly only on a  
4x20 LCD.
+-- A counter is printed to show the running forever loop.
+--
+
+include 16f88
+
+pragma target   CLOCK 20_000_000        -- xtal frequency
+pragma target   OSC   HS
+pragma target   LVP disabled
+pragma target   WDT disabled
+
+enable_digital_io()
+
+var  bit  LED        is pin_A4           -- LED to see proper PIC startup
+
+const     LCD_ROWS  = 4                 -- 4x20 LCD
+const     LCD_CHARS = 20
+var  bit  LCD_RS        is pin_B6       -- LCD command/data select.
+var  bit  LCD_EN        is pin_B7       -- LCD data trigger
+var byte  lcd_dataport  is portA_low    -- LCD data
+
+portA_direction         = all_output    -- LCD data and LED on portA
+portB_direction         = all_output    -- LCD handshake lines on portB
+
+include lcd_hd44780_4                   -- LCD library with 4 data lines
+include print                           -- formatted output library
+include delay_any_mc                    -- delay library
+
+for 4 loop                              -- blink LED 4 times
+   LED = on
+   delay_100ms(2)
+   LED = off
+   delay_100ms(2)
+end loop
+
+const byte str1[] = "Hello world!"      -- define strings
+const byte str2[] = "third line"
+const byte str3[] = "fourth line"
+
+lcd_init()                              -- initialize LCD
+
+print_string(lcd, str1)                 -- show hello world!
+lcd_setcursor(2,0)                      -- to 3rd line
+print_string(lcd, str2)
+lcd_setcursor(3,0)                      -- to 4th line
+print_string(lcd, str3)
+
+var byte counter = 0
+
+forever loop                            -- loop forever
+
+   counter = counter + 1                -- update counter
+   lcd_setcursor(1,0)                   -- second line
+   print_byte_dec(lcd, counter)         -- output in hex format
+   delay_100ms(3)                       -- wait a little
+
+   if counter == 255 then               -- counter wrap
+      lcd_setcursor(1,1)                -- 2nd line, 2nd char
+      lcd = " "                         -- clear 2nd char
+      lcd = " "                         -- clear 3rd char
+   end if
+
+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