I have been involved with the PIC microcontrollers by Microchip Technology, Inc. since early 1999.  I got interested using the PIC after using the Basic Stamp II by Parallax, Inc.  I wrote several clock programs using the BSII and wanted to move the code over to the PIC instead of tying up my BSII module.  I then was interested in being able to compile my BSII programs for the PIC so I didn't have to spend much time learning assembly language.  That's when I found the PicBasic Pro Compiler by microEngineering Labs, Inc.

Editors The two editors I use for programming are
Programmers File Editor and

First Project

My first 'real' PIC project was a remote GPS display.  I mainly wanted to have a compass heading, but I also included the time and a MPH reading.  As you can see in these pictures, I have enclosed the project in an old floppy disk case.   I used a 4x20 serial LCD display (BPP-420L) from Scott Edwards Electronics, Inc.  Since the backlight is software selectable, I have a momentary push-button that toggles the backlight on and off.  I wired the DB-9 connector to provide external power for normal operation in the vehicle.  I also have installed a 9-volt battery to provide 'remote' operation.

Source Code

'PROGRAM: eagle_gps7bl.pbp
'Modified by Brian Skrentny, December 1999
'Modified last on June 27, 2000
'previously published at http://hgalore.dyndns.org/
'Program to read position data from a Eagle Explorer GPS and display it on
'a Scott Edwards 4 X 20 LCD display at 9600 baud using PIC 16C558.
'Original program written by Decade Engineering
'to work with the Garmin and LCD display.
' *****  Scott Edwards 4X20 LCD control codes  *****

'Home_Cursor  	CON 01 			'Home the display cursor
Bigchr  	CON 02 			'Start big number display
'Blank_Cursor 	CON 04 			'Turn off cursor
'Underline_Cursor CON 05 		'Underline cursor
'Blink_Blk_Cursor CON 06 		'Blinking block cursor
'Back_Space  	CON 08 			'Back space the cursor
'Line_Feed  	CON 10 			'Move down one row
'Vertical_Tab 	CON 11 			'Move up one row
Clear_Screen 	CON 12 			'Clear the screen (Form feed)
'Carriage_Return CON 13 		'Return to start of next line
blon		CON 14 			'Turn backlight on
bloff		CON 15 			'Turn backlight off
pcurs		CON 16 			'Position cursor at xxx
'Clear_Column 	CON 17 			'Clear a column
dpin		CON 6 			'LCD display pin, PIC pin 12
N9600   	CON 6			'LCD Baudrate (9600,n,8,1)
N29600   	CON $4054		'LCD Baudrate (9600,n,8,1)
GPS_Pin  	CON 0			'GPS data input pin, PIC pin 6 (PORTB.0)
N4800   	CON 16572		'GPS baudrate (4800)
tz		CON 5			'Time zone (4=EST,5=CST,6=MST,7=PST) - st flag adds 1

DEFINE 	CHAR_PACING	2500		'2500 microsecond delay for LCD

time	var byte(4) 	'Unformatted time: 4533= XX:45:33 UTC
hr	var byte	'Hour in CST or CDT - set using tz
Cse	var word	'Whole number course (no decimal)
cmp	var byte(2)	'Course direction
Spd	var word	'Whole number speed in kts.(no decimal)
Spdt	var byte	'Tenths position
Speed	var byte	'Speed in MPH
gpsfix  var byte	'GPS status, A = good data, V = bad data
update	var bit		'status flag
indent	var bit		'indent flag
st	var bit		'standard time flag
bl	var bit		'backlight flag
 pause 2000
 bl = 0
if PORTB.1 then		'check switch/jumper if Standard or Daylight savings time
	st = 1		'switch/jumper off - standard time
	st = 0		'switch/jumper on - daylight savings time
 gosub clrscr				'Clear display
 serout dpin,N9600,[pcurs,71,"N9LOO"]
 update = 1 : indent = 0		'reset flags
 if PORTB.2 = 0 then blight		'Check for backlight button (PIC pin 8)
 serin2 GPS_Pin,N4800,2100,no_data,[wait("RMC,"),dec2 hr,str time\4,skip 1,gpsfix,wait("W,"),dec Spd,dec Spdt,dec Cse]
 if update = 0 then id
 if gpsfix="A" then good_fix
 if gpsfix="V" then bad_fix
goto get_data
 gosub clrscr						'Clear display
 serout dpin,N9600,[pcurs,88,"PLEASE WAIT"]		'data not reliable
 serout dpin,N9600,[pcurs,107,"WHILE POSITION"]
 serout dpin,N9600,[pcurs,125,"IS BEING ACQUIRED"]
 update = 0
 goto get_data
 Spd = (Spd * 10) + Spdt		'Multiply Knots by 10 (includes tenths for accuracy)
 Speed = (Spd */ $0127) / 10		'Multiply by 1.151 to convert Knots to MPH and / 10
 if hr > ((tz - 1) + st) then		'check if next day (UTC)
	hr = hr - (tz + st)		'subtract hr's according to time zone (5=CDT, 6=CST)
	hr = 24 - ((tz + st) - hr)	'subtract hr's from previous day

 if cse < 23 then north				'determine heading
 if cse < 68 then northeast
 if cse < 113 then east
 if cse < 158 then southeast
 if cse < 203 then south
 if cse < 248 then southwest
 if cse < 293 then west
 if cse < 338 then northwest
 if cse < 361 then north

 cmp(0) = "N" : cmp(1) = " " : indent = 1	'N
goto dsp_cmphd

 cmp(0) = "N" : cmp(1) = "E"			'NE
goto dsp_cmphd

 cmp(0) = "E" : cmp(1) = " " : indent = 1	'E
goto dsp_cmphd

 cmp(0) = "S" : cmp(1) = "E"			'SE
goto dsp_cmphd

 cmp(0) = "S" : cmp(1) = " " : indent = 1	'S
goto dsp_cmphd

 cmp(0) = "S" : cmp(1) = "W"			'SW
goto dsp_cmphd

 cmp(0) = "W" : cmp(1) = " " : indent = 1	'W
goto dsp_cmphd

 cmp(0) = "N" : cmp(1) = "W"			'NW

 if indent = 0 then skip_indent
 serout dpin,N9600,[pcurs,64,bigchr,"   ",pcurs,67,bigchr,cmp(0)] : indent = 0
goto dsp_time
 serout dpin,N9600,[pcurs,64,bigchr,cmp(0),cmp(1)]

 serout2 dpin,N29600,[pcurs,74," ",dec2 hr,":",time(0),time(1),":",time(2),time(3)]

 serout2 dpin,N29600,[pcurs,116,dec Speed," MPH "]
goto get_data

 gosub clrscr
 serout dpin,N9600,[pcurs,67,"NO SERIAL DATA"]
 serout dpin,N9600,[pcurs,105,"PLEASE CONNECT GPS"]
 serout dpin,N9600,[pcurs,128,"AT 4800 BAUD"]
' update = 0					'Never gets to ID since check is skipped, but ok
goto get_data					'Need to add pause and goto id if desired
 serout dpin,N9600,[Clear_Screen]		'Clear display
 pause 250
	'pause 250				'needed to move since slow checking
	branch bl, [bln, blff]
	serout dpin,N9600, [blon]
	bl = 1 : pause 500			'debounce switch
	goto get_data
	serout dpin,N9600, [bloff]
	bl = 0 : pause 500			'debounce switch
	goto get_data


Follow me

Smartphone Users

Get mobile app to scan tag

Check out my blogs!

I have two new blogs -Personal blog and my ham radio blog.

Go to top