Need more output pins for project

Hello everyone

I am fairly new to Arduino's and coding so bear with me here. I am working on a project that utilizes 5 hall effect sensors and one gyroscopic sensor (6 inputs) and 4 relays (4 outputs) and I have pretty well run out of output pins. I am using an Elegoo Arduino Uno R3, 5 KY-003 DC 5V hall effect sensors, and an MPU-6050 gyro. I was hoping to also use an LCD display to show the angle of the sensor in real-time however it will need to many outputs pins which I am already running out of.

I have heard of I2C and how it allows for multiple sensors to be on one line of sorts (that's how I understood it) however I haven't been able to find much information on how to use hall effect sensors with it.

If anyone knows a way to solve this problem I would love to hear it.

Thanks.

Probably easier to use the LCD on I2C

There are multiple interfaces available for sensors but every sensor is usually designed with one interface. Every interface costs silicon area and therefore money. So, unless your sensors has an I2C interface you cannot use I2C.
When you go to a manufacturer or a distributor web page you usually have search options to find sensors with the interface you like.

I recommend you look into the serial interfaces and the differences. You might like SPI even better. It requires more wires but is faster and more robust than I2C.

Upgrade what you have. The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 70 digital input/output pins (of which 15 can be used as PWM outputs, and 16 can be used as analog inputs), 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. When we plan a project we choose a uC based on the needs. All things considered moving to a better uC is likely the easiest path.

You could in some cases you mentioned use a MUX (Multiplex) and where sensors allow it I2C but I see the simplest method as using a more powerful uC with more IO capabilities.

Ron

Thank you for the advice everyone.

I have looked at I2C the LCD monitor however I don't believe I have the skills in coding to successfully pull it off.

I will take a look into SPI instead of I2C as it would save me a bit of money from buying a new Arduino, so thank you for that suggestion.

If all fails, I will buy an Arduino Mega as it seems to be the easiest solution to my problem.

Again thank you for the solutions!

stephane32:
I am working on a project that utilizes 5 hall effect sensors and one gyroscopic sensor (6 inputs) and 4 relays (4 outputs) and I have pretty well run out of output pins.

I assume you don't know you can also use the analogue pins as digital pins.
You then have eight pins for the LCD if you don't use an I2C backpack.
Leo..

Also you can use HC595 shift register to increase the amount of outputs.

The standard Uno has 18 pins that can be used for general digital I/O, 6 of which can read
analog values.

You claim to be using 6 inputs and 4 outputs, leaving 8 pins free. This doesn't add up...

Hi,
What is the project, application?
Thanks.. Tom.. :slight_smile:

stephane32:
I have looked at I2C the LCD monitor however I don't believe I have the skills in coding to successfully pull it off.

But you do not have the skills in coding to use any LCD in the first place. :cold_sweat:

Fortunately, you do not need any such skills. Bill Perry has a HD44780 library which you install using the IDE Library Manager and which then gives you example code with which to practice. There is negligible difference in using the code for direct connection of a display and I2C - in fact it is much easier to use I2C. :grinning:

The last thing you need is to use a Mega 2560. Cumbersome and troublesome. :astonished: