Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Receive string '?f' and clear the LCD in PIC16F628

Status
Not open for further replies.
Something like this

Code:
	call check_clear



check_clear

	movf	SER_IN,w
	andlw	'?'
	btfsc	STATUS,Z
	goto	NONE
	call	Rcv_RS232
	movf	SER_IN,w
	andlw	'f'
	btfsc	STATUS,Z
	goto	NONE
	movlw	1
	call	LCD_Cmd
NONE	retlw	0

Cheers Ian
 
Hey Ian, thank you so much! Also, how would you do this for '?g' if I want it to make a beep sound? My speaker is assigned to pin 6.

**broken link removed**
 
Hey Ian, thank you so much! Also, how would you do this for '?g' if I want it to make a beep sound? My speaker is assigned to pin 6.
You would duplicate the code posted, edit in the 'g' and have it call BEEP_Cmd , build BEEP_Cmd to make the beep.
 
Last edited:
Is it a speaker or a piezo buzzer? if its a buzzer turn RB0 on for 200mS then off ( short beep ) Also you may want to put a transistor on the buzzer. Or if it's a speaker you'll need to emit a 8 - > 15khz pulse to drive the speaker. Set up a counter to toggle the pin for about 200mS.

Cheers Ian
 
Last edited:
I updated the code as I wanted to make sure it was ok I also allowed for No LCD write when ? and f are sent
Code:
check_clear	movf	Rcv_Byte,w
		sublw	'?'
		btfss	STATUS,Z
		goto	no_buz
		call	Rcv_RS232
		movf	Rcv_Byte,w
		sublw	'f'
		btfss	STATUS,Z
		goto	no_clear
		movlw	1
		call	LCD_Cmd
		retlw	0	
no_clear	movf	Rcv_Byte,w
		sublw	'g'
		btfss	STATUS,Z
		goto	no_buz
		call	buzzer
		call	buzzer
		retlw	0
no_buz		movf	Rcv_Byte,w
		call	LCD_Char	
		return

cheers Ian
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top