November 23, 2024, 08:04:11 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Prop1 for Jeopardy Type Game

Started by RosehallManor, May 17, 2010, 12:45:07 PM

Previous topic - Next topic

RosehallManor

Besides making Halloween props, I also run the public education program at the fire department.  We have created a Jeopardy type game for our older elementary students.  I would like to make a pushbuttom type program for three teams.  Each team would be assigned a colored LED.  When a team hits their button, their LED would light up and the other two teams would be blocked from lighting their LED's.  After a minute or so the system would reset.  I need help with the program and a suggested design.  Can a Prop1 do this?  Anyone's help would be appreciated.

BigRez

May 17, 2010, 01:49:04 PM #1 Last Edit: May 17, 2010, 01:50:56 PM by bigrez
Have a look at this thread:  Game Show System Concept and see if that's similar to what you need.  I thought there was also another post similar to what you wanted - I'll search some more for it.

Yes, sounds like the prop-1 could do that:  3 input buttons, 3 output lights, (1 buzzer?)

Once you define what you have (or will use) someone here can write the program for you.

JonnyMac

May 17, 2010, 01:56:46 PM #2 Last Edit: August 07, 2010, 08:36:25 AM by JonnyMac
Here's something to get you started -- the code comments should help you understand how it works.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  ResetBtn        = PIN7                  ' SETUP = DN

SYMBOL  TeamCBtn        = PIN6                  ' SETUP = DN
SYMBOL  TeamBBtn        = PIN5
SYMBOL  TeamABtn        = PIN4

SYMBOL  ReadyLed        = PIN3

SYMBOL  TeamCLed        = 2
SYMBOL  TeamBLed        = 1
SYMBOL  TeamALed        = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  scan            = B2
SYMBOL  winner          = B3
SYMBOL  idx             = W5


' -----[ Initialization ]--------------------------------------------------

Reset:
 PINS = %00000000                              ' clear all outputs
 DIRS = %00001111                              ' make P0-P3 outputs

Rst_Hold:
 PAUSE 100
 scan = PINS & %11110000                       ' check inputs
 IF scan <> %00000000 THEN Rst_Hold            ' wait if any pressed

 ReadyLed = IsOn                               ' light ready lamp


' -----[ Program Code ]----------------------------------------------------

Main:
 scan = PINS & %01110000 / 16                  ' scan inputs
 IF scan = %000 THEN Main                      ' wait for something
   ReadyLed = IsOff                            ' show that we have it

 winner = 99                                   ' preset for tie
 LOOKDOWN scan,(%001, %010, %100), winner      ' find winner

 IF winner > 2 THEN Tie_Input                  ' we have a tie

Show_Winner:
 HIGH winner                                   ' light winner's LED

SW_Wait:
 FOR idx = 1 TO 100                            ' 100 x 100ms = 10s
   PAUSE 100
   IF ResetBtn = Yes THEN Reset                ' abort if Reset pressed
 NEXT
 GOTO Reset


Tie_Input:
 PINS = %00000000
 FOR idx = 1 TO 40                             ' 40 x 250ms = 10s
   PINS = PINS ^ %000000111                    ' flash team LEDs
   PAUSE 250
   IF ResetBtn = Yes THEN Reset                ' abort if Reset pressed
 NEXT
 GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Hello,

I was interested in a project like this as well and was following along with the thread.  However, I have noticed that Jon's program permits "ties".  I would prefer a lockout type program in which as soon as one person is first, it would lock out the others.  The program would be for the Prop-1 controller.

Thank You,

Geo


JonnyMac

It *permits* ties but that's not likely to happen -- the scan loop is very fast (a few hundred microseconds):

Main:
 scan = PINS & %01110000 / 16                  ' scan inputs
 IF scan = %000 THEN Main                      ' wait for something


As soon as there's any change the code drops through, locking out other inputs.
Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on August 07, 2010, 08:32:52 AM
It *permits* ties but that's not likely to happen -- the scan loop is very fast (a few hundred microseconds):

Main:
 scan = PINS & %01110000 / 16                  ' scan inputs
 IF scan = %000 THEN Main                      ' wait for something


As soon as there's any change the code drops through, locking out other inputs.

Thank you Jon for that answer, however, as rare as the situation is, what WILL happen if you get a tie?  Could you write the progam as to NOT allow a tie?  (Or would the code be too complex for the Prop-1?)

Thank You,

Geo


JonnyMac

The program is already written to tell you there was a tie -- you can change that as you see fit.  My thought is that you have to say there was a tie as the "contestants" will be pressing the buttons; if nothing happens this is confusing.  

While it wouldn't be fair, you could create a random variable that "fixes" a tie.  For example:

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  ResetBtn        = PIN7                  ' SETUP = DN

SYMBOL  TeamCBtn        = PIN6                  ' SETUP = DN
SYMBOL  TeamBBtn        = PIN5
SYMBOL  TeamABtn        = PIN4

SYMBOL  ReadyLed        = PIN3

SYMBOL  TeamCLed        = 2
SYMBOL  TeamBLed        = 1
SYMBOL  TeamALed        = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  scan            = B2
SYMBOL  winner          = B3
SYMBOL  pos             = B4
SYMBOL  tie             = B5
SYMBOL  idx             = B6

SYMBOL  lottery         = W5


' -----[ Initialization ]--------------------------------------------------

Reset:
 PINS = %00000000                              ' clear all outputs
 DIRS = %00001111                              ' make P0-P3 outputs

Rst_Hold:
 PAUSE 100
 scan = PINS & %11110000                       ' check inputs
 IF scan <> %00000000 THEN Rst_Hold            ' wait if any pressed

 ReadyLed = IsOn                               ' light ready lamp


' -----[ Program Code ]----------------------------------------------------

Main:
 RANDOM tie                                    ' randomize for ties
 scan = PINS & %01110000 / 16                  ' scan inputs
 IF scan = %000 THEN Main                      ' wait for something
   ReadyLed = IsOff                            ' show that we have it

Get_Winner:
 winner = 99                                   ' preset for tie
 LOOKDOWN scan,(%001, %010, %100), winner      ' find winner
 IF winner <= 2 THEN Show_Winner               ' we have a winner

Fix_Tie:
 RANDOM tie                                    ' re-randomize
 pos = tie // 3                                ' make 0 to 2
 LOOKUP pos, (%001, %010, %100), mask          ' convert to mask
 mask = scan & mask                            ' isolate one "random" input
 IF mask = 0 THEN Fix_Tie                      ' not part of tie?, do over
   scan = mask                                 ' copy to scan
   GOTO Get_Winner                             ' proceed as usual

Show_Winner:
 HIGH winner                                   ' light winner's LED

SW_Wait:
 FOR idx = 1 TO 100                            ' 100 x 100ms = 10s
   PAUSE 100
   IF ResetBtn = Yes THEN Reset                ' abort if Reset pressed
 NEXT
 GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------


Jon McPhalen
EFX-TEK Hollywood Office

jukingeo

Quote from: JonnyMac on August 08, 2010, 01:13:26 PM
The program is already written to tell you there was a tie -- you can change that as you see fit.  My thought is that you have to say there was a tie as the "contestants" will be pressing the buttons; if nothing happens this is confusing.  

While it wouldn't be fair, you could create a random variable that "fixes" a tie.  For example:


Perfect!  Thanx for the info / program.   Yeah, it may not be totally fair, but as you stated, it is a rare occurance to begin with.  It is just that I didn't want to be faced with the embarassment if all of a sudden the program DID spit out a tie situation...Just as well to avoid it in the first place.

As it turns out, years ago I did make the hard wired electronic version that was posted in the other thread about this, but there really isn't room to grow with that design.   With a micro controller you have much more flexibility in terms of what you want to do...such as adding chase lights, changing lighting patterns for the winner, etc.

Thank you,

Geo