this go in a car, it plays a sound track and flashes some leds with the sound track. It also lights the leds with the head lights and flashes them with the turn signals. there are two diffrent way it plays the soundtrack dependingon rather the car is running or not. I have to make the circut board for this as well so I need to know that this runs correctly so the PCB will work or if I need to change the PCB. That's where MPLAB SIM comes in, But I can't get it to work. I have till mid june to have everything complete and instaled in the car for a national show, that is design and make the PCB program the PIC and the sound track, put it all together and instal it. BTW I'm using a 16F628 chip.
'Declared variables
PLAYOUT var PORTA.0
RESET VAR PORTA.1
CAT_EYE_l VAR PORTA.2
CAT_EYE_R VAR PORTA.3
ARMED VAR PORTA.4
ACC VAR PORTB.0
LIGHTS VAR PORTB.1
TURN_L VAR PORTB.2
TURN_R VAR PORTB.3
PIR VAR PORTB.4
PUSH_BUTTON VAR PORTB.5
WAITOUT VAR PORTB.7
'DEFINE PORT DIRECTIONS & VALUES
TRISA = %11111111
TRISB = %11000000 'portb.6 and .7 out puts all others in put
'================================================= ==============================
'///////set initial pin states/////////////////////////
'================================================= ==============================
LOW PLAYOUT
LOW RESET
LOW CAT_EYE_L
LOW CAT_EYE_R
LOW ARMED
HIGH WAITOUT
'================================================= ==============================
'////////MAIN PROGRAM STARTS HERE//////////////
'================================================= ==============================
Pause 30000
LOW WAITOUT
HIGH ARMED
'================================================= ==============================
'///////MAIN LOOP STARTS HERE
'================================================= ==============================
MAIN:
IF ACC = 1 THEN
GOSUB RUN
ELSE
GOSUB SHOW
ENDIF
GOTO MAIN
'================================================= ==============================
'RUN LOOP STARTS HERE
'================================================= ==============================
RUN:
IF LIGHTS = 1 THEN
HIGH CAT_EYE_L
HIGH CAT_EYE_R
ELSE
LOW CAT_EYE_L
LOW CAT_EYE_R
ENDIF
IF PUSH_BUTTON = 1 THEN
GOSUB PLAY
HIGH ARMED
LOW WAITOUT
ENDIF
GOSUB TURN
RETURN
'================================================= ==============================
'SHOW LOOP STARTS HERE
'================================================= ==============================
SHOW:
IF PIR = 1 THEN
LOW ARMED
HIGH WAITOUT
GOSUB PLAY
PAUSE 60000
LOW WAITOUT
HIGH ARMED
ENDIF
RETURN
'================================================= ==============================
'PLAY STARTS HERE
'================================================= ==============================
PLAY:
LOW ARMED
HIGH WAITOUT
HIGH CAT_EYE_L
HIGH CAT_EYE_R
PulsOut RESET,10
Pause 100
PulsOut PLAYOUT,10
Pause 820
LOW CAT_EYE_L
LOW CAT_EYE_R
Pause 50
HIGH CAT_EYE_L
HIGH CAT_EYE_R
Pause 2550
LOW CAT_EYE_L
LOW CAT_EYE_R
Pause 50
HIGH CAT_EYE_L
HIGH CAT_EYE_R
Pause 5500
LOW CAT_EYE_L
LOW CAT_EYE_R
RETURN
'================================================= ==============================
'TURN STARTS HERE
'================================================= ==============================
TURN:
IF LIGHTS = 1 THEN
IF TURN_L = 1 THEN
LOW CAT_EYE_L
ELSE
HIGH CAT_EYE_L
ENDIF
IF TURN_R = 1 THEN
LOW CAT_EYE_R
ELSE
HIGH CAT_EYE_R
ENDIF
ELSE
IF TURN_L = 1 THEN
HIGH CAT_EYE_L
ELSE
LOW CAT_EYE_L
ENDIF
IF TURN_R = 1 THEN
HIGH CAT_EYE_R
ELSE
LOW CAT_EYE_R
ENDIF
ENDIF
RETURN




Bookmarks