Example Code - Parallax 28044 Manual

Hide thumbs Also See for 28044:
Table of Contents

Advertisement

Example Code

®
BASIC Stamp
2 Microcontroller
The following code example demonstrates features of the Laser Range Finder. This code is available for
download from the Parallax Laser Range Finder Module product page; search "28044" at
www.parallax.com.
This program uses the Debug Terminal, which is built into the BASIC Stamp Editor software. The
software is a free download from www.parallax.com/basicstampsoftware.
' =========================================================================
'
'
File....... LRF_Basic.bs2
'
Purpose.... Demonstrates features of the Parallax Laser Range Finder Module
'
Author..... Joe Grand, Grand Idea Studio, Inc. [www.grandideastudio.com]
'
E-mail..... support@parallax.com
'
Updated.... 30 JUN 2011 (v1.1)
'
'
{$STAMP BS2}
'
{$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
'
' This program demonstrates the Parallax Laser Range Finder (LRF) Module.
'
' When the pushbutton switch is pressed, the Laser Range Finder calculates
' the distance between itself and the target object. The result is
' displayed on a Parallax Serial LCD Module (#27977 backlight or #27976
' non-backlight).
'
' When the measurement is out-of-range (outside of the defined minimum or
' maximum distance bounds of the Laser Range Finder), the piezo buzzer
' will sound a warning tone.
'
' -----[ Revision History ]------------------------------------------------
'
' 1.0: Initial release
'
' -----[ I/O Definitions ]-------------------------------------------------
Enable
PIN
Piezo
PIN
LCD_TX
PIN
LRF_TX
PIN
LRF_RX
PIN
' -----[ Constants ]-------------------------------------------------------
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T1200
CON
T2400
CON
T4800
CON
T9600
CON
T19K2
CON
T38K4
CON
#CASE BS2SX, BS2P
T1200
CON
T2400
CON
Copyright © Parallax Inc.
0
' Pushbutton switch (active LOW)
12
' Piezo element (for alarm sound)
13
' Serial output to LCD
8
' Serial output to LRF (connects to SIN)
9
' Serial input from LRF (connects to SOUT)
813
396
188
84
32
6
2063
1021
Parallax Laser Range Finder (#28044)
v1.0 9/16/2011 Page 21 of 24

Advertisement

Table of Contents
loading

Table of Contents