'7-16-12 Modified to operate from the 8 GPOI pins on Raspberry Pi ' four pins choose cameras, four pins select scan time (1, 2, 4, 8 - additive) '01-13-2012 - Web Cam Video Switcher - revised reversing switch numbers '5-5-12 notes: Would not properly compile from Dell Desktop /w new software 'had to use the little Dell with the USB programmer - saved hex file ' as 1.4OK ' was not working properly with pin 3 as input when first programmed 'remember to set pin4 as input in programmer settings ' NOTE- must set MCLR_OFF pin to input in programmer, not here! ' CANNOT PROGRAM using ICSP with Switch for UseCamera3 ON ! ! ! DEFINE DEBUG_REG PORTA DEFINE DEBUG_BIT 0 'a.0 is PIN 13 on 16f684 DEFINE DEBUG_BAUD 9600 DEFINE DEBUG_MODE 1 'DEBUG mode: 0 = true, 1 = inverted option_reg.7=0 'turn on weak pull ups wpu = %00100010 'weak pull ups ansel=0 'use pins as digital rather than analog CMCON0= 7 'Disable comparator - makes portc LEDs work properly DEFINE OSC 8 'use 8 mhz oscillator OSCCON = $70 'set clock speed INTCON = %00001100 '00xx11xx to be CCP1 mode SerialOut var porta.0 'pin 13 Time1 var porta.1 'pin 12 Camera1 var porta.2 'pin 11 Camera2 var portc.0 'pin 10 Camera3 var portc.2 'pin 8 Camera4 var portc.1 'pin 9 Time2 var porta.5 'pin 2 Time4 var portc.3 'pin 7 UseCamera4 VAR porta.4 'pin 3 UseCamera3 VAR porta.3 'pin 4 UseCamera2 VAR portc.5 'pin 5 UseCamera1 VAR portc.4 'pin 6 temp var byte temp2 var word PotReading var byte Delay VAR word Test VAR byte CommandIN VAR byte 'data from web page Loopie VAR word Loopie2 var word Cam1On VAR Bit '=0 if off, =1 if on Cam2On VAR Bit Cam3On VAR Bit Cam4On VAR Bit TimeFudge con 10 trisa = %00111010 trisc = %11111000 'testtop: DEBUG 10,13,10,13,10,13,"Video Switcher - LEDs, Four Switches & Raspberry Pi for WebCam",10,13 DEBUG "(c) d. bodnar v 1.4 07-16-12",10,13 Start: 'debug "pins ",#time1," ",#time2," ",#time4,10,13:goto start: time1=not(time1):time2=not(time2):time4=Not(time4) delay = time1*2+time2*4 + Time4*8 'gives range of 2 seconds to 14 seconds delay=14-delay if Delay = 0 then delay = 1' if all time pins off then = 1 second 'adcin 7,PotReading 'Delay = potreading *100 'adjust up or down to change scan range 'Delay = Delay * 1000 ' DEBUG "Delay Time = ",#delay,10,13 goto start: IF UseCamera1=0 THEN debug "one active",10,13 LOW Camera2:LOW Camera3:LOW Camera4 HIGH Camera1 PAUSE Delay ENDIF IF UseCamera2=0 THEN debug "two active",10,13 LOW Camera1:LOW Camera3:LOW Camera4 HIGH Camera2 PAUSE Delay ENDIF IF UseCamera3=0 THEN debug "three active",10,13 LOW Camera1:LOW Camera2:LOW Camera4 HIGH Camera3 PAUSE Delay ENDIF IF UseCamera4=0 THEN debug "four active",10,13 LOW Camera1:LOW Camera2:LOW Camera3 HIGH Camera4 PAUSE Delay ENDIF IF UseCamera1=1 AND UseCamera2=1 AND UseCamera3=1 AND UseCamera4=1 THEN debug "NONE active",10,13 LOW Camera1:LOW Camera2:LOW Camera3:LOW Camera4 ENDIF GOTO Start: