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.

help needed for 7 segment display

Status
Not open for further replies.

mainman

New Member
I'm looking to code a 16f84 PIC chip that makes a seven segment display output H E L P. I've looked all over the internet with no luck. I was wondering if anyone knew any code that would help?


many thanks
 
You just need to switch four different patterns to the display, you're unlikely to find EXACTLY what you want, because it's such a strange request - but it's trivial to do.
 
hi,
If you use the good example that 'mabauti' has posted, you will have to extend the Bcdto7Seg table and pointers, to cover 'HELP'
 
Here is the body of the code I wrote for you.The initialize part and the delay you can do.In this example PORTA connecting to common cathodes & segment pins connects to PORTB.
Note that With this simple method you can only show letters.

Code:
;NOTES***********************************************************

;COMMON CATHODE SEGMENTS DISPLAY "HELP"

;COMMON CATHODES SHOULD CONNECT TO PORTA ACORDING TO THIS TABLE

;SEGMENTS STARTING FROM LEFT TO RIGHT

;SEG4	SEG3	SEG2	SEG1
;H	E	L	P
;RA0	RA1	RA2	RA3


;SEGMENT PINS SHOULD CONNECT TO PORTB ACORDING TO THIS TABLE
;SAME PINS LINKS TO OTHER SEGMENT PINS

;SEGMENT A-RB0
;SEGMENT B-RB1
;SEGMENT C-RB2
;SEGMENT D-RB3
;SEGMENT E-RB4
;SEGMENT F-RB5
;SEGMENT G-RB6

;DELAY SHOULD BE ABOUT 10MS

;****************************************************************

HELLO	 MOVLW B'00001'		;TURN ON RA0 & OFF OTHERS
	 MOVWF PORTA
	 MOVLW B'1110011'	;DISPLAY LETTER P
	 MOVWF PORTB
	 CALL  DELAY 
	
	 MOVLW B'00010'		;TURN ON RA1 & OFF OTHERS
	 MOVWF PORTA
	 MOVLW B'0111000'	;DISPLAY LETTER L
	 MOVWF PORTB
	 CALL  DELAY 

	 MOVLW B'00100'		;TURN ON RA2 & OFF OTHERS
	 MOVWF PORTA
	 MOVLW B'1111001'	;DISPLAY LETTER E
	 MOVWF PORTB
	 CALL  DELAY 

	 MOVLW B'01000'		;TURN ON RA3 & OFF OTHERS
	 MOVWF PORTA
	 MOVLW B'1110110'	;DISPLAY LETTER H
	 MOVWF PORTB
	 CALL  DELAY
	 GOTO  HELLO
 
Gayan has provided a simple, elegant, intuitive example which should be more than enough to get the OP started.
 
Code:
Device 16F877

Xtal = 4

Dim Number As Byte
	
Initialization:

	TRISB = %00000000               ' Make PORTB all outputs

	Number = 0                      '
		
Main:
	 
	 Number = 0

	 Repeat                                    ' Create a loop
		  
		 Inc Number                        ' Increment the Number register
		 
		 GoSub Encode_Segment_Display      ' Convert to segment data and display it
		 
		 DelaymS 500                       ' Small delay to slow down counting
		  
	 Until Number = 4                         ' Loop until number = 4, then reset

	 Goto Main                                 ' Loop forever
	 
Encode_Segment_Display:

	SELECT Number
	    CASE 1			
	   		 PORTB = %01110110
	    CASE 2			
			 PORTB = %01111001
	    CASE 3			
	   		 PORTB = %00111000
	    CASE 4			
	   		 PORTB = %01110011
	ENDSELECT
	
	Return

Click here to watch this program/circuit in action
**broken link removed**


Hope that helps (The circuit shows a "1" - its just a saved piccy on my site, watch the video to see "H E L P" displayed on the segment)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top