Temp project using LM34


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Ok thank you for the helpful ideas I've used those ideas now I want to incorporate an LED alarm that when the temp gets to >=80 degrees F that the LED 0 will flash and I won't be able to turn the alarm off until the temp goes below 80 degrees and switch 2 has been pressed.

    Below I have the code that I've tried to put into the microcontroller but everytime i try to do something I get caught up with no display on the LCD, any help would be appreciated.

    Code:
    DEFINE  LCD_DREG	PORTD 	'data register
    DEFINE  LCD_RSREG	PORTE	'register select
    DEFINE  LCD_RSBIT	0		'pin number
    DEFINE  LCD_EREG	PORTE	'enable register
    DEFINE  LCD_EBIT 	1		'enable bit
    DEFINE  LCD_RWREG	PORTE	'read/write register
    DEFINE  LCD_RWBIT 	2		'read/write  bit
    DEFINE  LCD_BITS 	8		'width of data 
    DEFINE  LCD_LINES	2		'lines in display
    DEFINE  LCD_COMMANDUS	2000	'delay in micro seconds
    DEFINE  LCD_DATAUS 	20		'delay in micro seconds
    
    'Set the port directions.  We are setting PORTA.0 to an input, all rest outputs
    'all of PORTD is set to outputs to run the LCD
    'and all of PORTE as outputs even though PORTE has only 3 lines.
    
    TRISA = %11111111			'set PORTA lines
    TRISB = %00101111
    TRISD = %00000000			'set all PORTD lines to output
    TRISE = %00000000			'set all PORTE lines to output 
    							
    ADCON1=%10000010			'see discussion above
    OPTION_REG.7=0
    'Define the variables used
    ADVAL	VAR	BYTE			'create ADVAL to store result
    TEMP    VAR BYTE			'temperature Farenheit variable
    TEMPC	VAR BYTE			'temperature Celsius variable
    DEG CON 223 				'write an degree mark on lcd
    MODE	VAR BIT
    C		CON	1
    F		CON 0
    LED		VAR	BYTE
    'define the adcin parameters
    DEFINE	ADC_BITS	10		'Set number of bits in result
    DEFINE	ADC_CLOCK	3		'Set clock source (3=rc)
    DEFINE	ADC_SAMPLEUS	50	'Set sampling time in uS
    PAUSE 500
    LCDOUT $FE, 1				'clear screen 
    PORTB.4=0
    PORTB.5=0
    MODE=C
    
    LOOP:						'The main loop of the program
    	ADCIN 4, ADVAL 			'Read channel 0 to adval
    	ADVAL =(ADVAL*/500)>>2
        TEMP=ADVAL
    	TEMPC=((TEMP-32) *100) /180
    	IF TEMP<32 THEN TEMP=32	
    	IF TEMP>100 THEN TEMP=100
    	IF TEMP>=80 THEN GOSUB FLASH
    	IF PORTB.0=0 THEN
    		MODE=MODE^1
    		WHILE PORTB.0=0 : WEND
    		PAUSE 50
    		ENDIF
    		PAUSE 100
    	LCDOUT $FE, 1, "TEMP=" 			'go to home position
    	IF MODE=F THEN
    		LCDOUT DEC3 TEMPC,DEG, "C" 	'print to line 1 of 2 line display
    	ELSE
    		LCDOUT DEC3 TEMP,DEG, "F"
    	ENDIF
    GOTO LOOP
    END
    FLASH:
    PAUSE 100 				' pause .1 sec to hear tone
    HIGH PORTD.0
    PAUSE 350
    LOW PORTD.0
    PAUSE 350
    RETURN
    Last edited by Philley; - 1st May 2007 at 22:54.

Similar Threads

  1. Graphic LCD with PICbasic pro
    By amindzo in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th November 2012, 11:45
  2. Stuck with 85C temp on ds18b20
    By revelator in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd April 2009, 19:50
  3. Random Numbers
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 18th December 2008, 08:47
  4. help with write command
    By cphillips82 in forum General
    Replies: 9
    Last Post: - 20th April 2008, 23:49
  5. Project with PIC16F818 & LM34
    By fesparza in forum mel PIC BASIC
    Replies: 2
    Last Post: - 18th November 2005, 20:05

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts