'
=========================================================================
'
' File.......
KSC.BS2
' Purpose....
Kitchen Sink Coffin Controller
' Author..... Jon
Williams (based on code by Scary Terry)
' E-mail.....
jwilliams@parallax.com
' Started....
' Updated....
1/25/2005 (this version created on 17 JAN 2005)
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
'
=========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History
]------------------------------------------------
' *KSCJW4;
1/24/2005, first run, changed EOM pin number,
' revised audio
selections, changed timing, changed head servo idx range
' *KSCJW5; 1/25/2005,
minor timing changes.
' -----[ I/O Definitions
]-------------------------------------------------
Trigger1
PIN 0 ' inputs
Trigger2
PIN 15
Head
PIN 1 ' head servo
Mouth
PIN 12 ' high to enable mouth
BoxShake
PIN 2 ' control outputs
Fogger
PIN 3
Lid
PIN 4
CorpseUp
PIN 5
CorpseDn
PIN 6
IsdA8
PIN 8 ' ISD2575 control
IsdA7
PIN 9
IsdA6
PIN 10
IsdCE
PIN 11 '100us low triggers
ChipCorder
IsdEOM
PIN 13 'EOM is low pulse
' -----[ Constants
]-------------------------------------------------------
IsHigh
CON 1
IsLow
CON 0
IsOn
CON 1 ' active-high control
IsOff
CON 0
IsUp
CON 1
IsDown
CON 0
Growl1
CON 0 ' audio selections
Growl2
CON 1
LidSqueak
CON 2
RoarScream
CON 3
ThankYou
CON 4
Rtn2Sender
CON 5
ShookUp
CON 7
' -----[ Variables
]-------------------------------------------------------
audio
VAR Nib ' audio select (0 - 7)
idx
VAR Byte ' loop control
' -----[ EEPROM Data
]-----------------------------------------------------
' -----[ Initialization
]--------------------------------------------------
Reset:
LOW Mouth ' make
outputs, set to off
LOW BoxShake
LOW Fogger
LOW Lid
LOW CorpseUp
LOW CorpseDn
LOW IsdA8 ' ISD25xx
control
LOW IsdA7
LOW IsdA6
HIGH IsdCE
' -----[ Program Code
]----------------------------------------------------
Wait_For_Trigger:
DO
IF (Trigger1 =
IsLow) THEN Routine_1
IF (Trigger2 =
IsLow) THEN Routine_2
LOOP
' **********************
' Activated by Trigger 1
' **********************
Routine_1:
audio = Growl1
GOSUB Play_Audio
BoxShake = IsOn
GOSUB
Wait_For_Audio
BoxShake = IsOff
PAUSE 1000
audio = Growl2
GOSUB Play_Audio
BoxShake = IsOn
Fogger = IsOn
GOSUB
Wait_For_Audio
BoxShake = IsOff
Fogger = IsOff
PAUSE 1000
audio = LidSqueak
GOSUB Play_Audio
Lid = IsUp
GOSUB
Wait_For_Audio
PAUSE 1000
CorpseUp = IsOn
BoxShake = IsOn
audio =
RoarScream
GOSUB Play_Audio
GOSUB
Wait_For_Audio
BoxShake = IsOff
PAUSE 500
GOSUB
Turn_Head '
turn to audience
Mouth = IsOn
audio = ThankYou
GOSUB Play_Audio
GOSUB
Wait_For_Audio
PAUSE 500
GOSUB
Return_Head '
back to sleep
audio =
Rtn2Sender
GOSUB Play_Audio
CorpseUp = IsOff
PAUSE 2000
CorpseDn = IsOn
PAUSE 400
CorpseDn = IsOff
PAUSE 1500
Lid = IsDown
GOSUB
Wait_For_Audio
Mouth = IsOff
audio = ShookUp
GOSUB Play_Audio
BoxShake = IsOn
PAUSE 7000
BoxShake = IsOff
GOTO
Wait_For_Trigger
' **********************
' Activated by Trigger 2
' **********************
Routine_2:
Fogger = IsOn
PAUSE 500
Lid = IsUp
audio = LidSqueak
GOSUB Play_Audio
PAUSE 1000
Fogger = IsOff
audio =
RoarScream
GOSUB Play_Audio
CorpseUp = IsOn
BoxShake = IsOn
PAUSE 2000
BoxShake = IsOff
GOSUB Turn_Head
Mouth = IsOn
audio = ThankYou
GOSUB Play_Audio
GOSUB
Wait_For_Audio
audio = ThankYou
GOSUB Play_Audio
GOSUB
Wait_For_Audio
PAUSE 50
Mouth = IsOff
GOSUB Return_Head
CorpseUp = IsOff
PAUSE 1000
CorpseDn = IsOn
PAUSE 400
CorpseDn = IsOff
PAUSE 1500
Lid = IsDown
PAUSE 300
audio = LidSqueak
GOSUB Play_Audio
GOTO
Wait_For_Trigger
' -----[ Subroutines ]-----------------------------------------------------
' This routine plays the selected message.
' -- put audio file (0 - 7) into 'audio'
Play_Audio:
IsdCE =
IsHigh '
make sure it's high
IsdA6 =
audio.BIT0 ' set audio address
IsdA7 =
audio.BIT1
IsdA8 =
audio.BIT2
PAUSE 25 ' let bus
settle
PULSOUT IsdCE,
50 ' start
the audio
RETURN
' This routine holds the program in place until the EOM
' (end of message) signal arrives from the ISD25xx
Wait_For_Audio:
DO : LOOP WHILE
(IsdEOM = IsHigh)
RETURN
' Turns head to "singing" position
Turn_Head:
LOW Head '
activate output
FOR idx = 1 TO 50
PULSOUT Head,
350 ' turn head
to viewer
PAUSE 20
NEXT
INPUT Head '
deactivate output
RETURN
' Returns head to "sleeping" position
Return_Head:
LOW Head '
activate output
FOR idx = 1 TO
100
PULSOUT Head,
1075 ' turn head
to sleep
PAUSE 20
NEXT
INPUT Head '
deactivate output
RETURN