M a r k   C r o s b i e

You are in: STAMP Buzzer and LCD  Home  Resume  Linux  LEGO  Electronics  Movies  Mac OS X 


Details
Overview Simple buzzer LCD control Buzzer and LCD PWM motor control Stepper motor control
Contact Mark at mark@mastincrosbie.com

STAMP Buzzer and LCD

This circuit is a slight enhancement to the simple buzzer circuit - I've added a LCD display that shows the current value being used to drive the buzzer. This simple project shows just how useful an LCD can be for debugging.

Remember, this is code for a Basic Stamp II only! It won't work on a BASIC Stamp I because the PBASIC commands have changed between Stamp versions.

Click here to download the source code.

' buzzlcd.bs2
' Buzz the speaker at a given tone based on the pot input,
' and display the value being used on the LCD.
' 
' The speaker is connected to pin 7
' The RC network is connected to pin 8
' The serial LCD connection is on pin 9
'
' NOTE: The LCD must be set to work on 2400 baud.
'
'       THIS IS CODE FOR A BASIC STAMP II ONLY!!
'
' Mark Crosbie January 1998. mark@mastincrosbie.com

' These are some predefined constants for controlling the LCD
LCDPREFIX	con	254
LCDCLS	con	1
LCDHOME	con	2
LCDBLANK	con	8
LCDSCRLLEFT	con	24
LCDSCRLRT	con	28
N24N	con	16780

result	var	word
dir9 = 1		' set the LCD pin to output
dir7 = 1		' set the speaker pin to output
serout 9,N24N,[LCDPREFIX, LCDCLS]	' clear the LCD

loop:
	high 8			' charge the capacitor
	pause 10		' wait for it to charge
	rctime 8,1,result	' do the RC timing
	freqout 7,10,result * 3 ' buzz the speaker
	serout 9, N24N, [dec ? result] ' display the result
	serout 9, N24N, ["   "] ' display some blanking text
	pause 10
	serout 9,N24N, [LCDPREFIX, LCDHOME] ' home the cursor
	goto loop
The LCD in this instance is a simple 2 line by 16 character display available from Scott Edwards Electronics. Using the LCD is simplicity itself - there are three lines to connect: Power (+5V), Ground (0V) and the serial input. The serial input can be driven directly from the Stamp output.

The LCD is set to 2400 baud in this example. There is a toggle switch on the back of the LCD backpack that allows you to choose between 2400 baud and 9600 baud communication. If you choose 9600 baud, you'll have to change the serial constant N24N.


 
cover
PIC Microcontroller Project Book
Lot's of great PIC project ideas!
cover

Programming and Customizing the Pic Microcontroller

If you are learning to program microcontrollers then Myke's book is good start.
cover
The Art of Electronics
A classic in the field. Teaches you the art and science of linear and digital electronic design. If you want to learn why your circuit is not working, read this book and you'll know why.
cover
Mobile Robots: Inspiration to Implementation
A very readable introduction to the art of robotic design and implementation from the best practioners in the field: the MIT Artificial Intelligence Lab!
cover
Microcontroller Cookbook
A set of cookbook style designs for the 8051 and PIC microcontrollers. A handy reference to have if you need a quick solution to a problem.

© 2002-2004 Mark Crosbie   shareright © 2002 Phlash