Author Topic: Help with Arduino based project  (Read 901 times)

0 Members and 1 Guest are viewing this topic.

Offline slambo511Topic starter

  • Newbie
  • Posts: 3
  • Country: gb
Help with Arduino based project
« on: August 13, 2017, 08:56:26 am »
Hello, this is my first post here and I am not really an electronics guy but a programmer, so please bear with me.

So I have a project which I use to teach students a number of concepts in programming, primarily binary, hexadecimal and low-level programming. It works by allowing the students to wire up a front panel with 10 inputs, each representing 1, 2, 4, 8, 16, 32, 64, 128, 256 and 512 respectively. As each connection is made the OLED display on the top outputs either the total in binary, hex and decimal or a simple instruction set.

I am using the I2C bus for the OLED.

My problem arises from my need for 10 inputs (one for each connector) and the Arduino not having that many to work with. I have looked at using ICs and the I2C bus, ICs and the SPI bus, relay banks, analog input using resistors to allow multiple switches on one input and a few other things I have forgotten  :wtf:

So my question, after all that, is this - what is the best approach and can you please elaborate.

Thanks in advance.
 

Offline LabRat

  • Contributor
  • Posts: 15
  • Country: gb
Re: Help with Arduino based project
« Reply #1 on: August 13, 2017, 09:08:10 am »
I have had good results with the MCP23017 port expander and there are arduino libraries available.  5v compatible, cheap and come in DIP package.  Would give more than enough extra I/Os for your needs.
Uses I2C but as long as the address is different than the OLED then there shouldn't be a problem sharing the same bus.
 
The following users thanked this post: slambo511

Offline Brumby

  • Supporter
  • ****
  • Posts: 12383
  • Country: au
Re: Help with Arduino based project
« Reply #2 on: August 13, 2017, 01:21:25 pm »
Do you have some analog inputs available?

If so, I might suggest you think about setting up your switches to some R-2R networks and use the output from them as input to an analog read.  All you have to do is set the range of analog levels for each binary value.

For example, if you use 3 switches per analogue pin, there will be 8 binary values which you would need to extract from the analog range of 0 to 1024.  This would give you a band of analog values of around +/- 64 from the mathematical expectation, which would allow high confidence in an accurate detection.  Use some 1% resistors and it shouldn't be too far off.  Experimentation can confirm before committing.

With 3 switches per pin, you could do 12 bits through 4 analog pins.

If you use 4 switches per pin, the bands become narrower: +/- 32.  You could do 12 bits in 3 analog pins, so long as the resistor network had the necessary precision and/or was mapped experimentally..
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf