7 Segment Display

A seven segment display contains seven LED ‘bars’ that can be lit up in different combinations to show the ten digits 0 to 9 and can also show some letters and other symbols.

Related Commands:

Print Page

Share

Schematic

PCB

Direct control of 7-segment display

This program will read an analogue input on pin C.0 and directly control a 7-segment display connected to the B.0 through B.6 output pins to show a value which represents that analogue level.

Code Example:
	dirsb = %01111111		; make B.0 to B.6 outputs

main:	readadc c.2, b1
	if b1 > 150 then show9
	if b1 > 130 then show8
	if b1 > 110 then show7
	if b1 > 90 then show6
	if b1 > 70 then show5
	if b1 > 50 then show4
	if b1 > 30 then show3
	if b1 > 20 then show2
	if b1 > 10 then show1
	
show0:	let pinsb = %00111111	' digit 0
	goto main

show1:	let pinsb = %00000110	' digit 1
	goto main

show2:	let pinsb = %01011011	' digit 2
	goto main

show3:	let pinsb = %01001111	' digit 3
	goto main

show4:	let pinsb = %01100110	' digit 4
	goto main

show5:	let pinsb = %01101101	' digit 5
	goto main

show6:	let pinsb = %01111101	' digit 6
	goto main

show7:	let pinsb = %00000111	' digit 7
	goto main

show8:	let pinsb = %01111111	' digit 8
	goto main

show9:	let pinsb = %01101111	' digit 9
	goto main
Copy Code Submit an Example

Create Module

No Image Selected

Bill of Materials

DescriptionCodeQty

Simulation

No Image Selected

Submit Your Own Code!

You must be logged in to submit code examples. Login now.

Comments

  • Login to leave a comment.