HomeArticlesProjectsBlogContact
Articles
5x7 Display
Colin Mitchell
Colin Mitchell
Make sure to subscribe to our newsletter and be the first to know the news.

Table Of Contents

01
Experiments
02
EXPERIMENT-23
03
EXPERIMENT-24
04
EXPERIMENT-25 "BULL'S EYE"

Experiments

Page9


EXPERIMENT-23

This experiment shows how to display a feature (such as an animation) AFTER a button has been pressed.
Press button “A” and SPLASH will show once:
To test the de-bounce feature, press and release the button very slowly. Notice that the animation only appears once. This is because the button must be released for 40h loops before it is recognised again. Try 20h loops (or less) and the animation will occur twice on some occasions. This proves how fast the micro is executing the program - it is performing 20h loops of the program in the time the button is released and the micro picks up the “bounce-pulses” at the end of the button-release to show SPLASH the second time.

Experiment-23 for “5x7 Display” Project
;PIC16F84 and only F84 chip
;Press button A for SPLASH! - with debounce

Start     ORG 0x00
          BSF 03,5     ;Go to page1 for setting-up the ports
          MOVLW 04h    ;Put 04 into W
          MOVWF 05h    ; to make RA2 input
          MOVLW 00h    ;Put 00 into W
          MOVWF 06h    ;and make port 6 (port B) all output
          BCF 03,5     ;Go to page0 for programming
          GOTO Main

Cell1     MOVLW 00h    ;place the 5 values into the 5
          MOVWF 11h     ; files to produce the first cell
          MOVLW 00h     ; as shown above.
          MOVWF 12h
          MOVLW 08h
          MOVWF 13h
          MOVLW 00h
          MOVWF 14h
          MOVLW 00h
          MOVWF 15h
          GOTO Scan

Cell2     MOVLW 00h     ;place the 5 values into the 5
          MOVWF 11h     ; files to produce the second cell
          MOVLW 1Ch     ; as shown above.
          MOVWF 12h
          MOVLW 14h
          MOVWF 13h
          MOVLW 1Ch
          MOVWF 14h
          MOVLW 00h
          MOVWF 15h
          GOTO Scan

Cell3     MOVLW 3Eh     ;place the 5 values into the 5
          MOVWF 11h     ; files to produce the third cell
          MOVLW 22h     ; as shown above.
          MOVWF 12h
          MOVLW 22h
          MOVWF 13h
          MOVLW 22h
          MOVWF 14h
          MOVLW 3Eh
          MOVWF 15h
          GOTO Scan

Cell4     MOVLW 41h      ;place the 5 values into the 5
          MOVWF 11h      ; files to produce the fourth cell
          MOVLW 41h      ; as shown above.
          MOVWF 12h
          MOVLW 41h
          MOVWF 13h
          MOVLW 41h
          MOVWF 14h
          MOVWF 15h
          GOTO Scan

Cell5     MOVLW 00h     ;place the 5 values into the 5
          MOVWF 11h     ; files to produce the fifth cell
          MOVLW 00h     ; as shown above.
          MOVWF 12h
          MOVLW 00h
          MOVWF 13h
          MOVLW 00h
          MOVWF 14h
          MOVLW 00h
          MOVWF 15h
          GOTO Scan

Scan      BSF 05,1      ;Reset 4017
          NOP
          BCF 05,1
          MOVF 11h,0    ;Move file 11 into W
          MOVWF 06h
          CALL DelD
          MOVF 12h,0    ;Move file 12 into W
          MOVWF 06h
          CALL DelD
          MOVF 13h,0    ;Move file 13 into W
          MOVWF 06h
          CALL DelD
          MOVF 14h,0    ;Move file 14 into W
          MOVWF 06h
          CALL DelD
          MOVF 15h,0    ;Move file 15 into W
          MOVWF 06h
          CALL DelD
          RETURN

DelD      DECFSZ 1Bh,1
          GOTO DelD
          MOVLW 00h     ;Zero port B to prevent mirroring
          MOVWF 06
Clk       BSF 05,0      ;Clock the 4017
          NOP
          BCF 05,0
          RETURN

Splash    MOVLW 50h     ;Each 10h represents 100mS
          MOVWF 0Ch
Splash1   CALL Cell1    ;Display Cell 1 for 1/2 sec
          DECFSZ 0Ch
          GOTO Splash1
          MOVLW 10h     ;Each 10h represents 100mS
          MOVWF 0Ch
Splash2   CALL Cell2    ;Display Cell 2 for 100mS
          DECFSZ 0Ch
          GOTO Splash2
          MOVLW 10h     ;Each 10h represents 100mS
          MOVWF 0Ch
Splash3   CALL Cell3    ;Display Cell 3 for 100mS
          DECFSZ 0Ch
          GOTO Splash3
          MOVLW 10h     ;Each 10h represents 100mS
          MOVWF 0Ch
Splash4   CALL Cell4    ;Display Cell 4 for 100mS
          DECFSZ 0Ch
          GOTO Splash4
          MOVLW 08h     ;Each 10h represents 100mS
          MOVWF 0Ch
Splash5   CALL Cell5    ;Display Cell 5 for 50mS
          DECFSZ 0Ch
          GOTO Splash5
          RETURN

Main      MOVLW 40h
          MOVWF 1Dh
Main1     BTFSC 05,2   ;Test for button A. NOT pressed line = LOW
          GOTO Main2   ;Pressed
          MOVF 1Dh,0   ;Not pressed
          XORLW 00
          BTFSC 03,2   ;Is file 1D = 0?
          GOTO Main1   ;Yes
          DECF 1Dh,1   ;No. Decrement Debounce file
          GOTO Main1
Main2     MOVF 1Dh,0   ;Move file 1D to W
          XORLW 00
          BTFSS 03,2    ;Is file 1D = 0? Is the zero-flag SET?
          GOTO Main1    ;No
          CALL Splash   ;Yes
          GOTO Main

  END

The block of numbers below is the HEX file for Experiment-23. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-23.hex

:100000008316043085000030860083127328003088
:1000100091000030920008309300003094000030CE
:1000200095003E28003091001C309200143093005F
:100030001C309400003095003E283E309100223064
:10004000920022309300223094003E3095003E28EA
:100050004130910041309200413093004130940092
:10006000413095003E280030910000309200003071
:10007000930000309400003095003E288514000065
:10008000851011088600512012088600512013089F
:100090008600512014088600512015088600512042
:1000A00008009B0B51280030860005140000051045
:1000B000080050308C0007208C0B5B2810308C001F
:1000C00012208C0B602810308C001D208C0B6528B2
:1000D00010308C0028208C0B6A2808308C003320CC
:1000E0008C0B6F28080040309D00051D7D281D08E1
:1000F000003A031975289D0375281D08003A031D51
:0601000075285920732848
:00000001FF

EXPERIMENT-24

This is an extension of experiment 23. Press button A to start and stop SPLASH animation. Button A becomes a TOGGLE BUTTON - with START/STOP feature.
It is important to label the flags so that you know exactly what they are indicating.
The two flags in this experiment detect the same thing (button-press) but their position in the program makes them detect different features.
Flag 1E,5 send s the micro to the SPLASH routine while 1E,4 detects when the button is NOT pressed so that the program can determine when a toggle action has occurred with the button.
Creating a toggle feature takes a lot of thought as the instructions must be placed in the right places in the program to achieve the desired result.

Experiment-24 for “5x7 Display” Project
;PIC16F84 and only F84 chip
;Press button A to START/STOP Splash animation

Start   ORG 0x00
        BSF 03,5    ;Go to page1 to set-up  the ports
        MOVLW 04h   ;Put 04 into W
        MOVWF 05h   ; to make RA2 input
        MOVLW 00h   ;Put 00 into W
        MOVWF 06h   ;and make port 6 (port B) all output
        BCF 03,5    ;Go to page0 for programming
        GOTO Main

Cell1   MOVLW 00h   ;place the 5 values into the 5
        MOVWF 11h   ; files to produce the first cell
        MOVLW 00h   ; as shown above.
        MOVWF 12h
        MOVLW 08h
        MOVWF 13h
        MOVLW 00h
        MOVWF 14h
        MOVLW 00h
        MOVWF 15h
        GOTO Scan

Cell2   MOVLW 00h    ;place the 5 values into the 5
        MOVWF 11h    ; files to produce the second cell
        MOVLW 1Ch    ; as shown above.
        MOVWF 12h
        MOVLW 14h
        MOVWF 13h
        MOVLW 1Ch
        MOVWF 14h
        MOVLW 00h
        MOVWF 15h
        GOTO Scan

Cell3   MOVLW 3Eh    ;place the 5 values into the 5
        MOVWF 11h    ; files to produce the third cell
        MOVLW 22h    ; as shown above.
        MOVWF 12h
        MOVLW 22h
        MOVWF 13h
        MOVLW 22h
        MOVWF 14h
        MOVLW 3Eh
        MOVWF 15h
        GOTO Scan

Cell4   MOVLW 41h    ;place the 5 values into the 5
        MOVWF 11h    ; files to produce the fourth cell
        MOVLW 41h    ; as shown above.
        MOVWF 12h
        MOVLW 41h
        MOVWF 13h
        MOVLW 41h
        MOVWF 14h
        MOVLW 41h
        MOVWF 15h
        GOTO Scan

Cell5   MOVLW 00h     ;place the 5 values into the 5
        MOVWF 11h     ; files to produce the fifth cell
        MOVLW 00h     ; as shown above.
        MOVWF 12h
        MOVLW 00h
        MOVWF 13h
        MOVLW 00h
        MOVWF 14h
        MOVLW 00h
        MOVWF 15h
        GOTO Scan

Scan    BSF 05,1        ;Reset 4017
        NOP
        BCF 05,1
        MOVF 11h,0     ;Move file 11 into W
        MOVWF 06h
        CALL DelD
        MOVF 12h,0     ;Move file 12 into W
        MOVWF 06h
        CALL DelD
        MOVF 13h,0     ;Move file 13 into W
        MOVWF 06h
        CALL DelD
        MOVF 14h,0     ;Move file 14 into W
        MOVWF 06h
        CALL DelD
        MOVF 15h,0     ;Move file 15 into W
        MOVWF 06h
        CALL DelD
        RETURN

DelD    BTFSC 05,2    ;A pushed? Pushed = HIGH
        GOTO Del1
        BCF 1E,4      ;Clear the button-pushed flag
        GOTO Del2
Del1    BSF 1E,4      ;Set the button-pushed flag
Del2    DECFSZ 1Bh,1
        GOTO Del2
        MOVLW 00h     ;Zero port B to prevent mirroring
        MOVWF 06
Clk     BSF 05,0      ;Clock the 4017
        NOP
        BCF 05,0
        BTFSS 05,2    ;A pushed?
        RETURN        ;A not pushed
        BTFSC 1E,4    ;Has the button been released?
        RETURN        ;No.
        BCF 1E,5      ;Yes. Don't send Micro to SPLASH
        RETURN

Splash  MOVLW 50h     ;Each 10h represents 100mS
        MOVWF 0Ch
Splash1 CALL Cell1    ;Display Cell 1 for 1/2 sec
        DECFSZ 0Ch
        GOTO Splash1
        MOVLW 10h     ;Each 10h represents 100mS
        MOVWF 0Ch
Splash2 CALL Cell2    ;Display Cell 2 for 100mS
        DECFSZ 0Ch
        GOTO Splash2
        MOVLW 10h     ;Each 10h represents 100mS
        MOVWF 0Ch
Splash3 CALL Cell3    ;Display Cell 3 for 100mS
        DECFSZ 0Ch
        GOTO Splash3
        MOVLW 10h     ;Each 10h represents 100mS
        MOVWF 0Ch
Splash4 CALL Cell4    ;Display Cell 4 for 100mS
        DECFSZ 0Ch
        GOTO Splash4
        MOVLW 08h     ;Each 10h represents 100mS
        MOVWF 0Ch
Splash5 CALL Cell5    ;Display Cell 5 for 50mS
        DECFSZ 0Ch
        GOTO Splash5
        RETURN

Main    BCF 1E,5      ;This flag sends micro to SPLASH
        BCF 1E,4      ;This flag detects button NOT pressed
Main1   BTFSS 05,2    ;Is button A pushed? Pushed = HIGH
        GOTO Main2    ;Not pressed
        BSF 1E,5      ;Pressed. Set 1E,5 flag
        CALL Splash
        GOTO Main1
Main2   BTFSS 1E,5
        GOTO Main1
        CALL Splash
        GOTO Main1

  END

The block of numbers below is the HEX file for Experiment-24. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-24.hex

:100000008316043085000030860083127D2800307E
:1000100091000030920008309300003094000030CE
:1000200095003E28003091001C309200143093005F
:100030001C309400003095003E283E309100223064
:10004000920022309300223094003E3095003E28EA
:100050004130910041309200413093004130940092
:10006000413095003E280030910000309200003071
:10007000930000309400003095003E288514000065
:10008000851011088600512012088600512013089F
:100090008600512014088600512015088600512042
:1000A0000800051955281E1256281E169B0B5628A7
:1000B00000308600051400000510051D08001E1AFA
:1000C00008009E12080050308C0007208C0B652819
:1000D00010308C0012208C0B6A2810308C001D20F0
:1000E0008C0B6F2810308C0028208C0B7428083063
:1000F0008C0033208C0B792808009E121E12051DDF
:1001000084289E1663207F289E1E7F2863207F28D8
:00000001FF

EXPERIMENT-25 “BULL’S EYE”

This is a simple ”Hit the LED” game. The LEDs flash randomly on the screen and the player is required to press button B when the centre LED is illuminated. When the “Bull’s Eye” is hit, a siren sound will be produced from the piezo.
The program has a number of interesting features.
One of the biggest problems with computers is the generating of random numbers. Computers are not very good at doing this. In this program we need to produce random numbers for the LEDs on the screen, and every 6th to 8th LED needs to be the centre LED. There are two ways to do this. One is a random number generator and the other is to produce a long table. If the table is long enough, the player will not be aware of any pattern or repetition. This is the simplest approach as we need the centre LED illuminated at regular intervals.
The second feature is the co-inciding of the button-press with the illuminated LED. This sounds complicated but it can be done with a simple sub-routine. To make sure the button is pressed ONLY when the LED is illuminated, the routine has to check the button is NOT PRESSED before the centre LED is lit.
This program has only one cycle of operation. You are required to add more “Bull’s Eye’s” and make it more complex. The “Bull’s Eye” section in the Main routine is identified. Simply copy the random LEDs sections (the sets of four instructions in the Main routine), then add another Bull’s Eye section. Make sure the GOTO statement is anything other than “x”
The Siren routine has been taken from Library of Routines with a couple of changes.
The Delay routine has been taken from a previous experiment and the clocking of the “shift register” has been explained previously.
Even though this program consists of over 100 lines of code, many are repetitions and other lines of code have been produced previously.
The Delay routine determines the length of time the LED is illuminated on the screen. Three routines are provided: short, medium and long.
“Row” sub-routine clocks the shift register (4017) to the desired row then the required LED is turned on.
If you want to produce a more-complex game, the main program will become very large. The only alternative is to produce the LEDs via a random number generator. After every 6 - 10 random number, a “Bull’s Eye” code is generated and in this way an infinite, random game will be created.
For the moment we will stick to simple, “Linear Programming” and you can change and improve the “Bull’s Eye” program.

Experiment-25 for “5x7 Display” Project ;PIC16F84 and only F84 chip
;“Bull’s Eye”

Start   ORG 0x00
        BSF 03,5    ;Go to page1 for setting-up the ports
        MOVLW 08h   ;Put 08 into W
        MOVWF 05h   ; to make RA3 input
        MOVLW 00h   ;Put 00 into W
        MOVWF 06h   ;and make port 6 (port B) all output
        BCF 03,5    ;Go to page0 for programming
        BCF 1E,7    ;Clear the flag bit
        GOTO Main

Delay1  MOVLW 01
        MOVWF 1Ah
Del1A   DECFSZ 1Bh,1
        GOTO Del1A
        DECFSZ 1Ch,1
        GOTO Del1A
        DECFSZ 1Ah,1
        GOTO Del1A
        RETURN

Delay2  MOVLW 02
        MOVWF 1Ah
Del2A   DECFSZ 1Bh,1
        GOTO Del2A
        DECFSZ 1Ch,1
        GOTO Del2A
        DECFSZ 1Ah,1
        GOTO Del2A
        RETURN

Delay3  MOVLW 03
        MOVWF 1Ah
Del3A   DECFSZ 1Bh,1
        GOTO Del3A
        DECFSZ 1Ch,1
        GOTO Del3A
        DECFSZ 1Ah,1
        GOTO Del3A
        RETURN

Siren   MOVLW 01h     ; = 1 loop
        MOVWF 1Ch     ; of Siren sound
SirnD   MOVLW 10h     ;No of on-off cycles
        MOVWF 0Eh
        MOVWF 10h
        MOVLW 30h     ;No of steps
        MOVWF 0Fh
        MOVLW 50h     ;Determines frequency
        MOVWF 0Ch
Repeat  MOVF 0C,0
        MOVWF 0D
On      BSF  06,7
        DECFSZ 0D,1
        GOTO On
        MOVWF 0D
Off     BCF 06,7
        DECFSZ 0D,1
        GOTO Off
        DECFSZ 10h,1
        GOTO Repeat
        DECF 0C,1
        INCF 0E,1
        MOVF 0E,0
        MOVWF 10h
        DECFSZ 0F,1
        GOTO Repeat
        DECFSZ 1C,1   ;1 cycle of Siren sound
        GOTO SirnDel
        RETURN

Row1    BSF 05,1      ;The row routine clocks the 4017 to the required row
        NOP
        BCF 05,1
        Return

Row2    BSF 05,1
        NOP
        BCF 05,1
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        Return

Row3    BSF 05,1
        NOP
        BCF 05,1
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        Return

Row4    BSF 05,1
        NOP
        BCF 05,1
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        RETURN

Row5    BSF 05,1
        NOP
        BCF 05,1
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        NOP
        BSF 05,0
        NOP
        BCF 05,0
        RETURN

Main    CALL Row1
        MOVLW 01
        MOVWF 06
        CALL Delay1
        CALL Row5
        MOVLW 08
        MOVWF 06
        CALL Delay2
        CALL Row3
        MOVLW 20
        MOVWF 06
        CALL Delay3
        CALL Row4
        MOVLW 10
        MOVWF 06
        CALL Delay1
        CALL Row1
        MOVLW 01
        MOVWF 06
        CALL Delay1
        CALL Row3
        MOVLW 20
        MOVWF 06
        CALL Delay1
        CALL Row1
        MOVLW 02
        MOVWF 06
        CALL Delay1
        CALL Row2
        MOVLW 04
        MOVWF 06
        CALL Delay1

        BTFSC 05,3   ;Button B pressed? This is the "Bull's Eye" section
        BSF 1E,7
        CALL Row3
        MOVLW 08
        MOVWF 06
        CALL Delay1
        BTFSS 05,3
        GOTO x
        BTFSC 1E,7
        GOTO x
        CALL Siren

x       CALL Row5
        MOVLW 02
        MOVWF 06
        CALL Delay1

        CALL Row4
        MOVLW 08
        MOVWF 06
        CALL Delay3

        CALL Row5
        MOVLW 04
        MOVWF 06
        CALL Delay2

        CALL Row5
        MOVLW 20
        MOVWF 06
        CALL Delay2

        CALL Row2
        MOVLW 10
        MOVWF 06
        CALL Delay2

        CALL Row3
        MOVLW 40
        MOVWF 06
        CALL Delay1

        CALL Row3
        MOVLW 20
        MOVWF 06
        CALL Delay1

        CALL Row2
        MOVLW 40
        MOVWF 06
        CALL Delay3

        BCF 1E,7
        GOTO Main

 END

The block of numbers below is the HEX file for Experiment-25. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-25.hex

:100000008316083085000030860083129E137B28FB
:1000100001309A009B0B0A289C0B0A289A0B0A288D
:10002000080002309A009B0B13289C0B13289A0B94
:100030001328080003309A009B0B1C289C0B1C28DB
:100040009A0B1C28080001309C0010308E00900094
:1000500030308F0050308C000C088D0086178D0BCF
:100060002E288D0086138D0B3228900B2C288C03A4
:100070008E0A0E0890008F0B2C289C0B2528080058
:1000800085140000851008008514000085100514F3
:1000900000000510080085140000851000000514FC
:1000A000000005100000051400000510080085146C
:1000B0000000851000000514000005100000051464
:1000C000000005100000051400000510080085144C
:1000D0000000851000000514000005100000051444
:1000E00000000510000005140000051000000514B4
:1000F000000005100800402001308600082067201D
:100100000830860011204B20203086001A2057200E
:1001100010308600082040200130860008204B2047
:10012000203086000820402002308600082044202D
:1001300004308600082085199E174B200830860061
:100140000820851DA6289E1BA62823206720023094
:10015000860008205720083086001A2067200430C7
:1001600086001120672020308600112044201030A6
:10017000860011204B204030860008204B20203084
:10018000860008204420403086001A209E137B28D9
:1001900040200830860008205720103086001120AB
:1001A0004B20043086001120672002308600112089
:1001B0004B2020308600082067200430860008206D
:0201C0007B289A
:00000001FF

Go to the next page of experiments: 5x7 EXPERIMENTS: Page-10



Colin Mitchell

Colin Mitchell

Expertise

electronics
writing
PIC-Chips

Social Media

instagramtwitterwebsite

Related Posts

TODO
Transistor Test
© 2021, All Rights Reserved.

Quick Links

Advertise with usAbout UsContact Us

Social Media