;This program will show you cycle glitter between 8 led lamps
Reference address:Design of fancy water lamp 4 (MCU-Assembly)
; maker:Chen Weiwu
; date:2012-11-08
; version:1.0.0
;-------------------------------------------------------------
;Define
Ledprt equ p0
SegDisplay equ p2
Button equ p1
ButtonState equ 30h
;----------------------
;Set the initiation address which the program runing
;----------------------
org 0
ajmp main
;-----------------------
Cycle:
mov a,#low(Tables)
add a,r1
mov dpl,a
clr a
addc a,#high(Tables)
mov VAT, a
;---------------------- Get Table's Address
clr a
movc a,@a+dptr
mov r1,a
move to,#1
movc a,@a+dptr
mov dpl,a
mov dph,r1
;----------------------
clr a
movc a,@a+dptr ;Get the count of data in table
mov r0,a
inc dptr
;----------------------
mov ButtonState,button ;Save button
Loop:
mov a,button
cjne a,ButtonState,ExitCycle ;Buttion is change
clr a
movc a,@a+dptr
mov Ledprt,a
acall delay
inc dptr
djnz r0,Loop
ExitCycle:
right
;-----------------------
;-----------------------
;delay sub
delay: mov r5,#50
delay1: mov r6,#100
DELAY2: mov r7,#10
djnz r7,$
djnz r6,delay2
djnz r5,delay1
right
;-----------------------
ButtonTable:
;--------ONE BUTTON--------
db 11111110B
DB 11111101B
db 11111011B
DB 11110111B
;--------TWO BUTTON--------
DB 11111100B
db 11111010B
DB 11110110B
DB 11111001B
db 11110101B
DB 11110011B
;-------THREE BUTTON-------
DB 11111000B
DB 11110100B
DB 11110010B
DB 11110001B
;-------FOUR BUTTON-------
DB 11110000B
DB 0
;-----------------------
Tables: dw Table1,Table2,Table3,Table4
dw Table5,Table6,Table7,Table8,Table9,Table10
dw Table11,Table12,Table13,Table14
dw Table15
dw 0
;-----------------------
Table1: db Table2-$-1
db 11101111b
db 11011111b
db 10111111b
db 01111111b
db 11111110b
db 11111101b
db 11111011b
db 11110111b
db 11111011b
db 11111101b
db 11111110b
db 01111111b
db 10111111b
db 11011111b
Table2: db Table3-$-1
db 01111110b
db 10111101b
db 11011011b
db 11100111b
db 11011011b
db 10111101b
Table3: db Table4-$-1
db 01010101b
db 00000000b
db 10101010b
db 00000000b
Table4: db Table5-$-1
db 11111110b
db 11111100b
db 11111000b
db 11110000b
db 11100000b
db 11000000b
db 10000000b
db 00000000b
db 00000001b
db 00000011b
db 00001111b
db 00011111b
db 00111111b
db 01111111b
db 11111111b
Table5: db Table6-$-1
db 00000000b
db 11111111b
Table6: db Table7-$-1
db 00001111b
db 00011110b
db 00111100b
db 01111000b
db 11110000b
db 01111111b
db 00111111b
db 00011111b
Table7: db Table8-$-1
db 00110110b
db 01010110b
db 01100110b
db 01101010b
db 01101100b
db 01101010b
db 01100110b
db 01010110b
Table8: db Table9-$-1
db 01110111b
db 10110111b
db 11010111b
db 11100111b
db 11101011b
db 11101101b
db 11101110b
db 11101101b
db 11101011b
db 11100111b
db 11010111b
db 10110111b
Table9: db Table10-$-1
db 11100111b
db 11000011b
db 10100101b
db 01100110b
Table10: db Table11-$-1
db 01111111b
db 10111111b
db 11011111b
db 11101111b
db 11110111b
db 11111011b
db 11111101b
db 11111110b
db 01111110b
db 10111110b
db 11011110b
db 11101110b
db 11110110b
db 11111010b
db 11111100b
db 01111100b
db 10111100b
db 11011100b
db 11101100b
db 11110100b
db 11111000b
db 01111000b
db 10111000b
db 11011000b
db 11101000b
db 11110000b
db 01110000b
db 10110000b
db 11010000b
db 11100000b
db 01100000b
db 10100000b
db 11000000b
db 01000000b
db 10000000b
db 10000000b
db 10000000b
db 01000000b
db 11000000b
db 10100000b
db 01100000b
db 11100000b
db 11010000b
db 10110000b
db 01110000b
db 11110000b
db 11101000b
db 11011000b
db 10111000b
db 01111000b
db 11111000b
db 11110100b
db 11101100b
db 11011100b
db 10111100b
db 01111100b
db 11111100b
db 11111010b
db 11110110b
db 11101110b
db 11011110b
db 10111110b
db 01111110b
db 11111110b
db 11111101b
db 11111011b
db 11110111b
db 11101111b
db 11011111b
db 10111111b
db 01111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
db 11111111b
Table11: db Table12-$-1
db 11111110b
db 01111111b
db 11111101b
db 10111111b
db 11111011b
db 11011111b
db 11110111b
db 11101111b
db 11110111b
db 11101111b
db 11111011b
db 11011111b
db 11111101b
db 10111111b
Table12: db Table13-$-1
db 00111100b
db 11111111b
db 11100111b
db 11111111b
db 11011011b
db 11011011b
db 11011011b
db 11011011b
Table13: db Table14-$-1
db 01111110b
db 11111111b
db 10111101b
db 11111111b
db 10111101b
db 11111111b
db 11011011b
db 11111111b
db 11011011b
db 11111111b
db 11011011b
db 11111111b
db 11100111b
db 11111111b
db 11100111b
db 11111111b
db 11100111b
db 11111111b
db 11100111b
db 11111111b
db 00000000b
Table14: db Table15-$-1
db 11111110b
db 11111100b
db 11111010b
db 11110100b
db 11101100b
db 11011010b
db 10111010b
db 01110101b
db 01110101b
db 01101101b
db 01101101b
db 01011011b
db 01011011b
db 00111011b
db 00111011b
db 00110111b
db 00110111b
db 00110111b
db 00110111b
db 00101111b
db 00101111b
db 00101111b
db 00101111b
db 00011111b
db 00011111b
db 00011111b
db 00011111b
db 00011111b
db 00011111b
Table15: db TableEnd-$-1
db 01111110b
db 10111110b
db 11011101b
db 11101101b
db 11110011b
db 11101101b
db 11011101b
db 10111110b
TableEnd:
;-----------------------
main:
mov Ledprt,#11111111B
move r2, #0
mov SegDisplay,#00H ;Initiate the SegDisplay
MOV DPTR,#ButtonTable
ToNext:
inc r2 ;Button Number
CLR A
MOVC A,@A+DPTR
JZ MAIN
INC DPTR
cjne a,button,ToNext ;Check whether the button is enable or not
mov SegDisplay,r2 ;button is enable,Show on the SegDisplay
mov a,r2
rl a
clr c
subb a,#2 ;Location in the Tables
mov r1,a
acall Cycle
ajmp Main
;-----------------------
end
;-------------------------------------------------------------
Previous article:Using STC15F104E MCU to Make Flashing Light
Next article:Design of fancy water lamp 2 (MCU-Assembly)
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Share the design of a comprehensive training platform for exploration and rescue robots based on the Internet of Things
- EEWORLD University ---- WPI-NXP demo
- Synchronous Rectification
- ESP32-Audio-Kit (8388 version) development environment setup video tutorial
- I'm going to make some IC chips. Please contact me if you need them.
- 6 steps to become an FPGA design expert
- Key Design Points for L-Band GaN Power Amplifiers
- What instruments do hardware engineers need?
- Stayed up late to sort out, and here comes the information about these components on the list~
- Which IDE is more suitable for Python?