# Using LED display

This is my current circuit. It's a 2 person colour guessing game. The first person will choose the colour code the other player has to try and guess using the registers on the left and then set the colour code by transferring it to the registers on the right by clicking the set code button down the bottom. The second player will then try to guess the colour. To check if the player has got the colour code correct they will press the guess colour button. If all 2 colours have been guessed correctly the hex display will display 2. If 1 colour has been guessed correctly the hex display will display 1 and if no colours have been guessed correctly the hex display will display 0. So for example, in the above picture, if the player pressed the guess colour button atm, the number 2 would be displayed as all colours are in their correct position.

The latter part is what I need help with. I have no idea how to wire up the circuit so that it can check whether or not the guesses are correct. Any help is greatly appreciated as I'm still learning.

• This sounds like a simplified verison of Mastermind, but your description of game play is too vague to be sure. – Dave Tweed Sep 8 '18 at 11:35
• Hint: An XOR gate will tell you whether two bits are different or the same. – Dave Tweed Sep 8 '18 at 11:37
• yep its just a smaller scale version of mastermind @DaveTweed – Mike Sep 8 '18 at 11:41
• You are getting better at writing your questions. – Misunderstood Sep 8 '18 at 14:58
• You need to add that your just trying to simulate this in logisim – Passerby Sep 9 '18 at 5:08

• You must start by defining the Game theory of operation and all the permutations of N colours ( N=4) in 4 positions.
• These can be defined by colours ABCD and positions 1234.
• Results can be displayed as a B/G bicolour LED with up to 4 indicators per guess.
• Both guesses and Results could be displayed AND saved for each of 12 guesses.
• Blue or Green indicators display the count of the correct colours in the False (F) and True (T) Positions in a discrete binary format
• each result indicator has two outputs for F/T Position count, not the actual position
• each guess entry can use a BCD finger wheel decimal switch to indicate a colour number for any number of colours such as 4 or even more
• A typical Mastermind game allows 12 guesses. so 4 inputs and 4 bicolour guesses could be displayed
• A blank colour as a 5th option = 0 could be considered or even more colours for the advanced player could be considered. This leads to N^C permutations.

## The display algorithm

• A count of 0,1,2,3,4 is 5 different results requires a 3-bit count and could be displayed using an RGB LED indicator with arbitrary colour assignments.

• Each position 's guess must be compared in a sequential manner to count B/G results using an XOR of 1 to 4 colours or numbers entered.

• This requires an XOR operation to count both correct colour and correct colour&position and subtract these to indicate the number of Blue or wrong position correct guesses.

A 2k ROM uC might be able to perform these operations to interface and drive these displays with up to 4x12 input guess RGB LEDs and 4x12 bicolour LEDs for results giving 96 LEDs to interface using I2C driven LEDs.

• If you wish to edit my specs and simplify it, feel free to copy and paste into your question what you prefer.
• Remember the best design always starts with a good clear specification of "Must Haves" and Nice to Haves ( or shall have or the lesser restriction, may have)
• +1 for taking the time to write it clearly. Maybe the logic could be implemented in a state machine using an EPROM with latched outputs. Would be a better way to learn basics than to use a µController. – Misunderstood Sep 8 '18 at 14:55
• I’ve seen Xilinx solutions with 10k FF’s and Muxes – Tony Stewart EE75 Sep 8 '18 at 14:58
• The whole thing could be done in a FPGA. The OP's circuit could be easily implemented in a small PLD. Then the EPROM inputs or outputs could be latched in the PLD. I did not take the time to think it through like you did, so I'm just kinda spitballing without fully understanding the question. – Misunderstood Sep 8 '18 at 15:06
• Maybe but depends how simple (1 state or 12 state) decision display is used. If 12 state, not likely unless you are an expert coder in 2k uc design. – Tony Stewart EE75 Sep 8 '18 at 15:17
• I do not know Mastermind. When it comes to games, I'm old school, I shoot pool and play pinball. By EPROM state machine I'm thinking something like this is what is needed. The logic is programed into the 27C256. electronics-diy.com/electronic_schematic.php?id=702 --- The clock would be generated by the press of any button. – Misunderstood Sep 8 '18 at 15:35

I am not familiar with Mastermind but if I understand what you are doing this should do it. A simple EPROM state machine.

I believe my only assumption is there are no random events.

This is a Finite State Machine where the LEDs determines the current state. The push button switches determine the transition to the next state.

The data register is clocked at 10 hz so it will catch each quick press of the button and debounce is no problem. You may need a slower clock if you cannot release the switch quick enough. You can also remedy holding the switch closed by programming in the EPROM state table where the only way to leave as state is by pressing a different switch to transition from one state to another. In other words pressing the same switch twice would not transition to another state.

I'm not sure if you are familiar with this circuit, I think it is fairly common. If not, I don't think the concept is too difficult to grasp. I searched the term EPROM state machine and got this tutorial link: Finite State Machine Programmable Logic Controller

I have not made one since 1985, but I think this will do it. I remember 1985 because the final product was on a April 1986 cover of PC Week Magazine, as IBM's first Ethernet card for a PC when they released the Micro Channel PC.