hmm, must be a IE thing, I use firefox or chrome and the video seem to work fine.
so sorry for the delay, I decided to make a about a hundred modules to build a
interactive light table, so took me a few days to get the layout finished before I sent off a test pcb run, here's the pbp code if anyone is interested, feel free to make it better, cooler, etc.... I'm going to wait to post the pcb gerber files, I placed an order that should be here next few days, just to check that everything works as planned then I'll post the pcb files.. (don't really like posting stuff that I'm not 100% sure is working, untill I have the boards in hand)
Code:
'****************************************************************
' MIBAM TEST pic12F683 / pic12f1822 *
'****************************************************************
#IF __PROCESSOR__ = "12F1822"
#MSG "Compililng for 12F1822..."
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _MCLRE_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01110000 '8mhz
TRISA = %00011000 'setup inputs/outputs
'ANSELA = %00010000 'RA4 = analog
ANSELA = %00001000
CM1CON0 = 0 'disable comarators
ADCON0 = %00001101 'Select AN3 enable ADC
ADCON1 = %11010000 'Right Justify - Fosc/16 & 8mhz
BTN var PORTA.3
#ELSE
#if __PROCESSOR__ = "12F683"
#msg "Compiling for 12F683..."
#CONFIG
__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
#ENDCONFIG
OSCCON = %01110001 '8mhz
TRISIO = %00011000 'setup inputs/outputs
ANSEL = %01011000 'RA4 = analog
CMCON0 = %00000111 'disable comarators
ADCON0 = %10001101 'Right Justify - Fosc/16 & 8mhz
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 wsave1-3
' --- IF any of these three lines cause an error ?? ------------------------
' Comment them out to fix the problem ----
' -- Which variables are needed, depends on the Chip you are using --
;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
ssave VAR BYTE BANK0 SYSTEM ' location for STATUS register
psave VAR BYTE BANK0 SYSTEM ' location for PCLATH register
' --------------------------------------------------------------------------
disable debug
;---------------------------------------------------------------------------
BTN var GPIO.3
#else
#ERROR "Only 12F1822 & 12F683 are supported!"
#endif
#ENDIF
DEFINE OSC 8 '8mhz
DEFINE DEBUG_REG PORTA 'serial output to get ADC levels
DEFINE DEBUG_BIT 5
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
BAM_COUNT CON 3 ; How many BAM Pins are used?
INCLUDE "MIBAM.pbp" ; Mirror Image BAM module
RED VAR BYTE
GRN VAR BYTE
BLU VAR BYTE
adc_val var word 'adc value variable
adc_last var word 'previous adc value
adc_thresh var word 'adc trigger threshold variable
adc_delta var word 'change in adc/value
Mode var byte 'currently selected effect mode
x var byte 'just a byte
ASM
BAM_LIST macro ; Define PIN's to use for BAM
BAM_PIN (PORTA,0, BLU) ; and the associated Duty variables
BAM_PIN (PORTA,1, RED)
BAM_PIN (PORTA,2, GRN)
endm
BAM_INIT BAM_LIST ; Initialize the Pins
ENDASM
Speed CON 5 'led fade speed
adc_thresh = 20 'trigger threshold (adjust to change sensitivity)
red = 0
blu = 0
grn = 0
MODE = 0
'------------------------ MAIN PROGRAM LOOP ------------------------
main:
if btn = 0 then 'check mode button
mode = mode + 1
pause 400
if btn = 0 then 'check to see if press/hold mode button (reset)
pause 2000 'reset if modules get out of sync on modes.
GIE = 1 'press mode button > 2.5 sec
for x = 1 to 5
red = 50
pause 40
red = 0
pause 40
next x
GIE = 0
red = 0
mode = 0
endif
if mode > 4 then
mode = 0
endif
endif
pause 30
gosub do_adc 'get ADC reading
gosub get_delta 'calculate delta since last reading
'debug "ADC: ", dec4 adc_Val, "--> ",dec4 adc_last," D: ", dec3 adc_delta,13,10
if adc_delta > adc_thresh then 'trigger effect if threshold exceded
GIE = 1
select case mode
case 0
gosub fadeR
case 1
gosub fadeG
case 2
gosub fadeB
case 3
gosub sparkle
case 4
gosub flash
end select
GIE = 0
pause 30
gosub do_adc
gosub get_delta
endif
goto main
'------------------------- SUBROUTINES ---------------------------------------
Do_Adc: 'sample ADC pin
adc_last = adc_val
pauseus 50
ADCON0.1=1
WHILE ADCON0.1 : WEND
adc_val.highbyte = ADRESH
adc_val.lowbyte = ADRESL
return
Get_Delta:
if adc_last = adc_val then
adc_delta = 0
return
else
if adc_last > adc_val then
adc_delta = adc_last - adc_val
else
adc_delta = adc_val - adc_last
endif
endif
return
'------------------- EFFECTS SECTION ------------------------
fadeB:
FOR BLU = 255 to 1 STEP -1
PAUSE Speed
NEXT BLu
blu = 0
return
fadeG:
FOR grn = 255 to 1 STEP -1
PAUSE Speed
NEXT grn
grn = 0
return
fadeR:
FOR red = 255 to 1 STEP -1
PAUSE Speed
NEXT red
red = 0
return
sparkle:
for x = 255 to 1 step -10
red = x
BLU = x
pause 30
red = 0
BLU = 0
pause 30
next x
return
flash:
red = 255
grn = 255
blu = 255
pause 30
red = 0
grn = 0
blu = 0
pause 30
return
I've tested the code on both 12F683 and 12F1822, works great, don't forget to grab the latest version of MIBAM in this thread above! thanks again Darrel!.
I'll post more pictures and video once I get the modules... stay tuned..
Bookmarks