Sam
clrf sc ; Sets Counter's loop amount to 256
clrf sc1
clrf sc2
clrf sc3
letS movlw b'000000' ; Clears all LED's to low
movwf GPIO
call delay100
movlw b'010111' ; Letter S Q1 Completly lit
movwf GPIO
call delay100
movlw b'000011' ; Letter S Q2 LED #4 lit
movwf GPIO
call delay100
movlw b'010111' ; Letter S Q3 Completly lit
movlw GPIO
call delay100
movlw b'010111' ; Letter S Q4 Completly lit
movwf GPIO
call delay100
decfsz sc,f ; Inner Loop Counter
goto letS
decfsz sc1,f ; 1st Middle Loop Counter
goto letS
decfsz sc2,f
goto letS
decfsz sc3,f
goto letS
;****************** Delay Subroutine ( 100 µs )
delay100 ; Delay W x 100 µs
movlw .25 ; Delay = ( N x 4 - 1 + 2 cycles = N x 4 + 1 )
movwf dc4 ; Writes 25 or N to register
dc5 nop ; No Operation
decfsz dc4,f ; Decrement Counter
goto dc5 ; If Decrement Counter is 0 then skips this if its not 0 then it loops untill 0
retlw 0
Multiplex
movlw b'11111111' ;make all pins input (all off)
tris GPIO
movlw b'00000001' ;GP0 high, all others low
movwf GPIO
movlw b'11111110' ;GP0 output
btfsc LEDs,0 ;is LED 1 lit
andlw b'11101111' ;yes, so make GP4 output
btfsc LEDs,1 ;is LED 2 lit
andlw b'11111101' ;yes, so make GP1 output
btfsc LEDs,2 ;is LED 3 lit
andlw b'11111011' ;yes, so make GP2 output
tris GPIO ;move to tris register
call Delay ;show the LEDs
movlw b'11111111' ;make all pins input (all off)
tris GPIO
movlw b'00000010' ;GP1 high, all others low
movwf GPIO
movlw b'11111101' ;GP1 output
btfsc LEDs,3 ;is LED 4 lit
andlw b'11111110' ;yes, so make GP0 output
btfsc LEDs,4 ;is LED 5 lit
andlw b'11101111' ;yes, so make GP4 output
btfsc LEDs,5 ;is LED 6 lit
andlw b'11111011' ;yes, so make GP2 output
tris GPIO ;move to tris register
call Delay ;show the LEDs
movlw b'11111111' ;make all pins input (all off)
tris GPIO
movlw b'00000100' ;GP2 high, all others low
movwf GPIO
movlw b'11111011' ;GP2 output
btfsc LEDs,6 ;is LED 7 lit
andlw b'11111110' ;yes, so make GP0 output
btfsc LEDs,7 ;is LED 8 lit
andlw b'11111101' ;yes, so make GP1 output
btfsc LEDs2,0 ;is LED 9 lit
andlw b'11101111' ;yes, so make GP4 output
tris GPIO ;move to tris register
call Delay ;show the LEDs
movlw b'11111111' ;make all pins input (all off)
tris GPIO
movlw b'00010000' ;GP4 high, all others low
movwf GPIO
movlw b'11101111' ;GP4 output
btfsc LEDs2,1 ;is LED 10 lit
andlw b'11111110' ;yes, so make GP0 output
btfsc LEDs2,2 ;is LED 11 lit
andlw b'11111101' ;yes, so make GP1 output
btfsc LEDs2,3 ;is LED 12 lit
andlw b'11111011' ;yes, so make GP2 output
tris GPIO ;move to tris register
call Delay ;show the LEDs
movlw b'11111111' ;make all pins input (all off)
tris GPIO
retlw 0
Debug build of project `C:\PIC12F509\Programs\LED_Cube_rev2 .disposable_mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Fri Aug 15 10:16:05 2008
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p12F509 "LED_Cube_rev2 .ASM" /l"LED_Cube_rev2 .lst" /e"LED_Cube_rev2 .err" /d__DEBUG=1
Error[113] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 93 : Symbol not previously defined (counter)
Error[113] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 96 : Symbol not previously defined (counter2)
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 116 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 118 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 120 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 129 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 131 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 133 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 142 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 144 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 146 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 155 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 157 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\PIC12F509\PROGRAMS\LED_CUBE_REV2 .ASM 159 : Register in operand not in bank 0. Ensure that bank bits are correct.
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `C:\PIC12F509\Programs\LED_Cube_rev2 .disposable_mcp' failed.
Preprocessor symbol `__DEBUG' is defined.
Fri Aug 15 10:16:06 2008
----------------------------------------------------------------------
BUILD FAILED
To do a decent job of it you really need 5x7 (35 LEDs). Maybe he doesn't want to do letters? (haven't read the entire thread)Ok guys, help me out here. I'm trying to get the OP to show me how he would physically lay out 12 LEDs to represent a letter. Is there a different way I can ask because he doesn't seem to understand?
loop
waitup movlw .2
call delay10 ; Delay of 20ms to debounce EITHER switch
btfsc GPIO,3 ; Is switch 3 pressed?
goto waitup ; Yes, wait 20ms and test again
test btfsc GPIO,3 ; Test's if GP3 skip's if high
goto test
movlw .255
call delay10
btfss GPIO,3 ; If button is still pressed then call's first sub
call #1Subroutine
btfsc GPIO,3 ; If button is not pressed then call second sub
call #2Subroutine
goto loop
;***** VARIABLE DEFINITIONS
temp EQU 0x07 ;example variable definition
LEDs EQU 0x08
LEDs2 EQU 0x09
cblock 0x07
;***** VARIABLE DEFINITIONS
dc1,dc2,dc3 ; Delay Loop Counters
dc4 ; Delay of 100 µs Variable
cv,cv1,cv2,cv3,cv4,cv5 ; Loop Counter Variables
LEDs
LEDs2
endc
;******** Main Code
start
movlw b'001000' ; Configure only GP3 as a input
tris GPIO
loop
waitup btfsc GPIO,3 ; Is switch 3 pressed?
goto TurnOn
;turn off LEDs
clrf LEDs
clrf LEDs2
goto Display
TurnOn movlw 0x55 ;try changing this value
movwf LEDs
movlw 0x05 ;and this one
movwf LEDs2
Display
call Multiplex
call Multiplex
call Multiplex
call Multiplex
goto loop
;****************** Delay Subroutine ( 10 ms )
----------------------------------------------------------------------
Debug build of project `C:\PIC12F509\Programs\LED_Cube_rev3 .disposable_mcp' started.
Preprocessor symbol `__DEBUG' is defined.
Sat Aug 16 21:04:46 2008
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p12F509 "LED_Cube_rev3 .ASM" /l"LED_Cube_rev3 .lst" /e"LED_Cube_rev3 .err" /d__DEBUG=1
Loaded C:\PIC12F509\Programs\LED_Cube_rev3 .cod.
----------------------------------------------------------------------
Debug build of project `C:\PIC12F509\Programs\LED_Cube_rev3 .disposable_mcp' succeeded.
Preprocessor symbol `__DEBUG' is defined.
Sat Aug 16 21:04:47 2008
----------------------------------------------------------------------
BUILD SUCCEEDED
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?