I would have liked to delete thread #18 because that issue was resolved, I was missing some piece of code for MIBAM.
Anyways, I started off using Sayzer's code, then I was able to bypass the POT and make the LEDs scan automaticly.
I then added the MIBAM code (with no apparent difference) and I am still back to square one; I am not able to have about 20 LEDs on at the same time (or appear to be) to produce an effect similar as the video in thread #11
I am obviously not getting it and I would appreciate some guidance.
Below is the code I have so far, it is turning on then off LED1 to LED64 at the right speed but I am trying to turn on LED1, LED2...LED20 and from there when LED21 turns on the LED1 will turn off, LED22 on - LED2 off and so on.
Code:
@ __config _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BOREN_OFF & _LVP_OFF & _CP_OFF
CLEAR
DEFINE OSC 20
BAM_COUNT CON 8
INCLUDE "MIBAM.pbp"
;____[ For 12F/16F only - Interrupt Context save locations]_________________
wsave var byte $20 SYSTEM ' location for W if in bank0
;wsave var byte $70 SYSTEM ' Alternate save location for W
' if using $70, comment out wsave1-3
; Comment them out to fix the problem ----
; -- The chip being used determines which variables are needed -------------
wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2
wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3
;---DO NOT change these-----------------------------------------------------
ssave VAR BYTE BANK0 SYSTEM ' location for STATUS register
psave VAR BYTE BANK0 SYSTEM ' location for PCLATH register
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 5
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
CM1CON0 = 0
CM2CON0 = 0
pauseus 10
ADCON1 = 0
ADCON0 = 0 ' All analog, we just need RA0.
TRISA = 255 ' PORTA all input. Others output.
TRISB = 0
TRISC = 0
TRISD = 0
test var byte
X var PORTB
Y var PORTC
x = 0 ; make sure all LEDs are off
y = 0 ; when powr is applied
I var byte
Index var byte
Index2 var byte
OldVal var byte
Pause 10
ASM
BAM_LIST macro ; Define PIN's to use for BAM
BAM_PIN (PORTB,0, X) ; and the associated Duty variables
BAM_PIN (PORTB,1, X)
BAM_PIN (PORTB,2, X)
BAM_PIN (PORTB,3, X)
BAM_PIN (PORTB,4, X)
BAM_PIN (PORTB,5, X)
BAM_PIN (PORTB,6, X)
BAM_PIN (PORTB,7, X)
endm
BAM_INIT BAM_LIST ; Initialize the Pins
ENDASM ' Mirror Image BAM module
Begin:
pause 500
;lcdout $fe,1,"Matrix Test"
;PAUSE 500
X = 0
Y = 255
index = 0
oldval = 255
Start:
; adcin 0, index ' Index = max 255.
for i = 0 to 255
index = i / 4 ' To get index values between 0 to 63.
;if oldval <> index then ' Act only when the number changes.
index2 = index/8 ' X scans 8 bits.
x = 0 ' turn it Off.
x.0[index2] = 1 ' Set the bit in line.
y = 255 ' turn all pins on (output is off).
lookup index2,[7,15,23,31,39,47,55,63],index2 ' Get matrix line.
y.0[index2-index] = 0 ' Clear the bit in line (output is on)
;lcdout $fe,$c0,dec3 index , " ",dec3 index2
;pause 10
oldval = index
;endif
pause 1
next i
pause 100
goto start
end
Bookmarks