The document contains code examples for displaying numbers and patterns on a 7-segment display using a microprocessor. It includes programs to display "HELLO WORLD", count up and down, blink LEDs, rotate LEDs in a pattern, and display the numbers 0-9 on a 7-segment display using both long and short methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
35 views6 pages
Microprocessor Basic Compiler Programs
The document contains code examples for displaying numbers and patterns on a 7-segment display using a microprocessor. It includes programs to display "HELLO WORLD", count up and down, blink LEDs, rotate LEDs in a pattern, and display the numbers 0-9 on a 7-segment display using both long and short methods.
RUNNING LED (0 to 8 then 8 to 0) TRISC = 0x00 PORTC = %00000001 goleft: WaitMs 500 PORTC = ShiftLeft(PORTC, 1) If PORTC.7 Then Goto goright Goto goleft goright: WaitMs 500 PORTC = ShiftRight(PORTC, 1) If PORTC.0 Then Goto goleft Goto goright End
4 LED LIGHT TRISC = 0x00 loop: PORTC = %0.0.0.0.1.1.1.1 WaitMs 0 PORTC = %11110000 Goto loop End
LED ON OFF TRISC = 0x00 loop: PORTC = %1111 WaitMs 100 PORTC = %0000 WaitMs 100 Goto loop End
TOGGLE SWITCH TRISA = %00000001 TRISC = %00000000 Symbol toggle1 = PORTA.0 toggle1 = 1 Symbol led1 = PORTC.0 loop: If toggle1 Then led1 = 1 Else led1 = 0 Endif Goto loop
ZERO TO NINE 7 SEGMENT SHORTCUT Dim digit As Byte Dim mask As Byte loop: TRISC = %00000000 For digit = 0 To 9 mask = LookUp(0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67), digit PORTC = mask WaitMs 300 Next digit Goto loop
SHORTCUT 0 TO B DIM digit as byte DIM mask as byte loop: TRISC = %00000000 for digit = 0 to b mask = lookup(0x3f, 0x79, 0x38, 0x38, 0x5c, 0x00, 0x4f, 0x5c, 0x77, 0x38, 0x4e), digit portc = mask waitms 200 next digit goto loop end
SHORTCUT 0 TO F DIM digit as byte DIM mask as byte loop: TRISC = %00000000 for digit = 0 to f mask = lookup(0x73, 0x1c, 0x6d, 0x74, 0x00, 0x78, 0x74, 0x79, 0x00, 0x7c, 0x1c, 0x78, 0x78, 0x5c, 0x54), digit portc = mask waitms 200 next digit goto loop end