Circuit for trivia game

Discussion in 'The Projects Forum' started by candro, Aug 2, 2014.

  1. candro

    Thread Starter New Member

    Aug 2, 2014
    4
    0
    I have a small system I made for playing Trivia. It consists of 3 momentary contact switches and some relays. Three players play at the same time much like Jeopardy. Each person has a switch. When a player know the answer to the question he/she presses their switch and illuminates a light in front of them. I have the circuit wired so that the other players are "locked out" until the circuit gets reset.

    What I would like to do is have a circuit that would allow the "lock out" but remember the sequence in which the switches were pressed.

    Example: If player 1 presses their switch first, player 2 presses their switch second, and player 3 presses their switch third I would like to see a light illuminated for player 1. If player 1 gave a wrong answer to the question I would like to press a reset, turn off the light for player 1 and then have the circuit automatically illuminate a light for the next player in the sequence. In this example it would be for player 2. After the completion of a round the circuit would need to be reset for another question.

    I hope this makes some sense. Suggestion will be greatly appreciated.
     
  2. AlphaDesign888

    New Member

    Jul 27, 2014
    189
    10
    You want to use an microcontroller or discrete logic chips?
     
  3. candro

    Thread Starter New Member

    Aug 2, 2014
    4
    0
    I don't want to spend an arm and a leg for the project. Whatever works for the least cost is okay with me.
     
  4. AlphaDesign888

    New Member

    Jul 27, 2014
    189
    10
    Well, personally I'd use an $1 microntroller. Something like an PIC16F628a
    And I'd write firmware for it in C.
    Begin by making an requirements list in dot form.
     
  5. candro

    Thread Starter New Member

    Aug 2, 2014
    4
    0
    Thanks for the info. I think me trying to program in C is not an option. I can follow a schematic and could wire a circuit board.
     
  6. AlphaDesign888

    New Member

    Jul 27, 2014
    189
    10
    Your project is custom. You won't find anyone on here that will have an schematic to hand you. I mean you might but I wouldn't hold my breath. It is a few hours labor to draw up an schematic for what you require using discrete parts.

    It would take me one hour to write C software though. C is the way to go for something like this. Your project is all logic.
     
  7. candro

    Thread Starter New Member

    Aug 2, 2014
    4
    0
    Again, thank you very much for your input.
     
  8. inwo

    Well-Known Member

    Nov 7, 2013
    2,433
    315
    I have an idea for a relay partial solution.:confused:

    Let me draw it up, to see if it expands to impracticable.:D
     
    Last edited: Aug 2, 2014
  9. inwo

    Well-Known Member

    Nov 7, 2013
    2,433
    315
    First attempt.

    Up to OP if it's too complex to be practical.

    There may be timing issues. :confused: Ties? More interlocks?

    If someone had a relay sim program it would be helpful. I'm not up for building it.:eek:

    Also may give some ideas for a chip solution.

    If it falls apart during my explanation, I'll have to start over.:D



    First three rungs latch players attempts in any order.

    Last three latch users "place". (only player A shown)

    1st place latches if "not" B or C.

    3rd place latches if A "and" B. (A and B are both pressed first)

    2nd place was the tricky one. Relay "exclusive or" is tough.
    So 2nd place lights if "not" 1st place and "not" 3rd place.

    edit:
    Needs a little work. :(
    I'll de-bug it in PLC!
     
    Last edited: Aug 2, 2014
  10. AlphaDesign888

    New Member

    Jul 27, 2014
    189
    10
    Pesudeo code it then C it.
     
  11. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    What happens as the first player to ring in is displayed? Won't that be a disincentive to the remaining players?

    How do you know its time for the next question? When reset doesn't display another player?

    Why is coding in C not an option? Have you never coded before and do not feel like learning? Microprocessors are a powerful tool in your design arsenal. Or is this a one time application, unrelated to electronics?
     
  12. crutschow

    Expert

    Mar 14, 2008
    13,042
    3,243
    I personally think the Basic language, whose syntax is closer to pseudo-code, is much easier to learn for a beginner then the cryptic and arcane syntax of C. Unless you are planning on programming large, complex programs I see no particular reason to go with C. Of course, that's just my opinion based upon programming a few small programs, my aversion to learning a complex language, and my preference for doing things the easiest way possible. Besides, C was originally conceived as an April Fool's Joke. ;)
     
    Last edited: Aug 2, 2014
  13. AlphaDesign888

    New Member

    Jul 27, 2014
    189
    10
    Yes BASIC is tops. More than capable of doing this project.
    I started off using BASIC, spent years using it, and did not merge to C until I formally studied Java.

    Java is pretty much C.
     
  14. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    If not for you Candro, perhaps for someone else who is looking for a software solution, I present the following pseudo-code. It is not necessarily any specific language, but presented as a potential solution. I currently have no way to test it, other than by playing computer.

    It doesn't address reading the pushbuttons, assuming that there are other functions written that check for any button press, and returns an integer corresponding to each button. Same for displaying the result. It assumes a function for that as well.

    The algorithm is based on a small array, sized to the total number of pushbuttons. This array stores the number of each button, in order of its being pressed. Hence the zeroth element of latch is the first button pressed, the 1st element is the second button pressed, etc...
    Each time reset is pressed, the elements are rotated, so the zeroth element is always the one to answer the question (hence why we display latch(0)). Previous values in the zeroth position are rotated to the end of the array, but stored as a negative. This allows the code to identify buttons previously pressed and allows the code to prevent them from "ringing in" again.
    Once the zeroth position has the value of 0, everyone has had a chance to answer, and the display goes dark, indicating that it is time for the next question. The re-initialization of the latch array will take place unnecessarily, but it is not extremely wasteful. To keep the code simple, I left it this way.

    Code ( (Unknown Language)):
    1. // buttons are identified by 1,2, or 3
    2. // negative values used to indicate a pushbutton
    3. // that has answered incorrectly.
    4.  
    5. int latch[3]={0,0,0,0}; // one extra position for testing previous pushed buttons
    6. int position = 0; // variable to hold which position is ringing in
    7. int i = 0; // scratch variable for looping through lists
    8. int hold = 0; // scratch variable to hold reset attempts
    9.  
    10. while -1
    11.     {
    12.     if any(pushbutton)
    13.         {
    14.         i=0;
    15.         // look through list of pushed buttons
    16.         while (latch(i) <> abs(pushbutton) AND i<=3) i++;
    17.         if (i>=3) // button not pressed in this game; save it in order
    18.             {
    19.             latch(position)=pushbutton;
    20.             position++;
    21.             }
    22.         }
    23.     // rotate list
    24.     if reset
    25.         {
    26.         hold=latch(0);
    27.         for {i=1;i<=2;i++} latch(i-1)=latch(i);
    28.         latch(2) = -hold;
    29.         }
    30.     if latch(0)>0
    31.         {
    32.         display latch(0); // show leading button
    33.         }
    34.     if latch(0)<=0
    35.         {
    36.         for {i=0;i<=3;i++} latch(i)=0;
    37.         }
    38.     }
    39.  
     
  15. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,812
    834
    @crutschow, I also agree that BASIC is easier to learn. I was specifically curious about the OPs comments regarding C.

    Personally, I've written quite complex systems in BASIC. My last project was a programming language, written in FreeBASIC. Of course, that language has many C-like constructs.
     
  16. AlphaDesign888

    New Member

    Jul 27, 2014
    189
    10
    Tab indents mate!

    You'd fail in an Australian University for those :eek:
     
  17. crutschow

    Expert

    Mar 14, 2008
    13,042
    3,243
    That looks a lot like C to me (that is, I doubt you could understand it without understanding the basics of C syntax). ;)

    This is a simple pseudo-code example closer to Basic and which can be generally understood by anyone who knows the English language:

    Code ( (Unknown Language)):
    1. //For i := 1 to 100 do
    2.     set print_number to true;
    3.     If i is divisible by 3 then
    4.         print "Fizz";
    5.         set print_number to false;
    6.     If i is divisible by 5 then
    7.         print "Buzz";
    8.         set print_number to false;
    9.     If print_number, print i;
    10.     print a newline;
    11. end
     
  18. crutschow

    Expert

    Mar 14, 2008
    13,042
    3,243
    Then I suppose it's good that I'm not going to an Australian University. :rolleyes:
     
  19. AlphaDesign888

    New Member

    Jul 27, 2014
    189
    10
    Well I did 3 Java units. Total 9 assignments, and 3 exams.
    With the assignments, it was stated that tab indents will lose you marks.

    Who am I to argue?
     
Loading...