Go Down

Topic: (4051) Analog Multiplexer / DeMultiplexer library update (Read 4 times) previous topic - next topic

ajfisher

Okay that makes more sense now.

So if you have 2 4051s and you want 16 inputs then there's pretty much only one way to attack this.

You have the 4051s separately and run each of them into a separate analog pin (if you want an analog reading on your button. If it's a push button then you can just attach it to a digital pin for reading as you're only checking on off statement).

Now you'll need to look at your data sheet for your pin out but essentially you end up with Vcc and GND, Vee you attach to ground as well.

Then you have what might be marked as INH or E - This is the input/output selector pin. This is USUALLY attached to ground if you want the 4051 to work as an INPUT. If you push it HIGH then it will work as an output instead.

Beyond that you'll have two sets of pins, one set of three usually marked as A, B and C and then another set marked 0 - 7.

The 0-8 are your inputs or outputs (depending on whether you set INH LOW or HIGH). They are what you connect your buttons to. I'm just going to call these pins inputs from now on for simplicity.

The 3 control pins are used to select which of the 8 inputs you want to switch to and then measure. These work as three binary values which collectively work together to create a 3 bit integer (providing the range 0-7).

Your data sheet will have the details of which pin represents each bit.

The last pin we haven't looked at yet, usually called Z or Out/In, is the one you connect to the arduino that you are going to read.

So once you know what your IC looks like, grounded the pins that need grounding, added +5v to the Vcc and wired up your buttons, and put the Z line to an Arduino input, you just need to set up your A, B, C pins to three digital outs on the Arduino to control the switching.

At this point I'll point you to this example in my library: https://github.com/ajfisher/arduino-analog-multiplexer/blob/master/examples/MuxPot/MuxPot.ino which uses potentiometers on three inputs to demonstrate connecting and reading the value.

Replace the pots with buttons, and make it 8 instead of 3 and you've pretty much got what you need. The library I built makes this dead simple and means you don't need to worry about the bit manipulation etc.

Really the key is to check your data sheet to orient yourself to the pin out and then use the concepts I've described above.

Cheers
Andrew


johnmlewis66

Thanks for this reply. It was very kind from you to take your time to give me an help.

I'm much clear now, soon as I get home I will make some tests.
Do you have any schematic of the potentiometers or something that I can follow to connect the buttons?
Any way, I will try to make this by myself and I will post my schematic and the code for debugging.

Once again, thanks for your help.

PS. I was able to follow the schematic of the 3 leds and make them to work with one IC4051.

johnmlewis66

Hi,

yesterday I started my first attempt of connecting the dartboard to arduino.
The problem I found, was the delay reading the value from the dart when hits the dartboard.
I was using the keypad library. The arduino have to scan all ROWS and COLS, scan one by one.
The problem is, sometimes, when the dart hits the dartboard, the arduino can cacth it. (The circuit is closed and opened very fast). Other times doesn't.
If I'm not wrong, arduino must read the correct ROW and COL at the exact time that the circuit is closed, when the dart hited the board.

Any suggestion?

Thanks!

michinyon

Your dartboard is not going to signal for enough time for the arduino to read it.

johnmlewis66

Exactly!
But do you know any way to by pass it?
How can I solve that problem?

Go Up