Pins, pins and more pins.

I am back to working on my plant watering system.

Alas a new problem has happened and I am seriously thinking of rebuilding the entire circuit.
I have already bought 5v relays to use.

My project “needs”:
5 outputs to drive relays (then 12v solenoids).
1 (analogue) input sensor.
1 Button. (at least one.)
RTC (I2C), so that’s 2 pins.
A “display”. (Work in progress here.)

What I “have”:
I bought an 8 relay (5v) board. Future compatible. I am sure there are more functions needing to be added.
1 x 7 segment display. I am thinking of making it 2. That will only cost me 2 more pins, as I will run it BCD and there will be 2 pins for digit selection and digit blanking.
An input button.
RTC

Doing a pin count, this is how I see things:
BCD bus: 4 pins
Digit blank 1 pin / digit. 2 pins if 2 digits.
Digit select 1 pin / digit. 2 pins if 2 digits.
8 relays - well may as well go the whole hog.
I2C bus. 2 pins.
Button. 1 pin.

That’s 19 pins so far.

Ok, I could cut back on 3 pins for relays as I am only using 5 for now… But…

So that is 16 Pins at a pinch.

I was thinking of using a LCD instead of the 2 x 7 segment displays.
http://m.banggood.com/5V-2004-20X4-204-2004A-LCD-Display-Module-Blue-Screen-For-Arduino-p-915064.html
But I’m not sure if that would really gain me any more pins.
There seems to be more pins on the main picture than the 8 I need now with the two 7 segment displays.

Going to a MEGA seems… “Overkill” in that I would go from too few pins to… WAY TOO MANY. Kind of thing.

Another thought is to get one of those I2C I/O chips… They only cost a few dollars and I have used one before.

Anyone got any suggestions on pin usage and the best option to get the needs of the project, vs pins available, to work?

Thanks.

Go for a serial or I2C LCD display. That will save a lot of pins.

An I2C port expander may also make sense for the 8 relays. But it seems like you aren't using all relays now so you could jus leave the others disconnected.

Future-proof your software by defining your own functions to turn relays on and off. Then if you do change to a port expander in the future you don't need to change the main part of the program, just one or two functions.

lost_and_confused: Going to a MEGA seems....... "Overkill"

No it isn't. You are already sailing very close to the wind and yet you only have two inputs. I bet this project is going to grow. They usually do, and usually because you want to add something tomorrow that you didn't think of last week. One sensor and a button seems particularly unambitious, so there is plenty of room to exercise your mind there.

I think these environmental projects usually run out of memory before they run out of pins, thereby needing a Mega on those grounds. The last thing you need is to make a decision on pins and find you have run out of both.

You already have an I2C clock, and I2C LCD display can share the pins.

When the UNO isn’t big enough and the Mega seems overkill, see the 1284P. Check out the bobduino from @Crossroads.

Bobuino is nice, 32 IO, and several different form factors available. http://www.crossroadsfencing.com/BobuinoRev17/ This one is Uno form factor. |500x209 Or this one, add a TPIC6B595 to drive 150mA relay coils, has RTC, and SD card for saving greenhouse related whatever. Screw terminals are an option. |500x388

Thanks to all.

(On a side note, I didn't get any notifications. AFAIK, the box is ticked and I have immediate notifications set.)

The bobuiono shall be looked into.

Just to clarify a couple of points: There is only one "input" but that can be "switched" (10 - 1, or 8 -1) kind of deal. 4028 for instance.

The one button is really there only for testing. I press the button and it runs the loop. As I use CLICKBUTTON, it allows me to add "multi-clicks" to the input. So I double click to get to a new menu. I triple click to get to another one.

I LONG CLICK to exit back to the main one.

Most of the "extra" menus are there only for minor adjustments insitu (?spelling?). (auto correct couldn't find the work I wanted.)

Oh, and maybe the button will be to enable/disable it if it is raining for weeks, or something like that.

I shall check my settings (again) to try and work out why I am not getting notifications.

Nobody else is either

lost_and_confused: Going to a MEGA seems....... "Overkill" in that I would go from too few pins to..... WAY TOO MANY. Kind of thing.

So why is 'WAY TOO MANY' pins a problem ?

You are allowed to leave pins unused ........

And if you read your own post over, your already planning for more pins ........................

Yes, true.

But at this point, I am "starting anew" with what is going to be done.

So I am adding a bit of extra stuff while I am at it.

:)

Mega

If I just needed digital I/O pins, then I would prefer to use I/O expanders like MCP23017. They are very easy to use, more expanders can easily be added, and they keep the physical size of the project down. On the other hand, if it's more of an "ad hoc" project or experiment, and size doesn't matter, then a Mega2560 or similar is always nice to have.

@rduino |500x364

Just asking, on an UNO:

There are pins 1 - 13 (13 being the LED).

Then there are the A0 - 5 pins.

Looking at a pinout thingy, I am still confused on their “numbers”.

On attached the A0 - A5 are numbered 23 - 28.

So are those the numbers I use if I want to use A0 as an output?

pinMode (23 OUTPUT);

But now looking, that doesn’t make sense.
Pins “1 - 13” are not numbered that. It ends in 19…
(And starts at 2)

I am really not having luck getting a “useful” Arduino UNO pinout cheat sheet.

Arduino_uno_Pinout.pdf (156 KB)

The numbers up to 28 are the pins of the physical device. 0-13 and A0 to A5 are the software names. A0 to A5 are also 14 to 19. 0 to 13 (D0 to D13) and A0 to A5 reflect the names on the board.

The white numbers in brown squares are the numbers your sketch will use. Example:

byte buttonName = 2; // use D2 for a button input.

Then

void setup(){
pinMode (buttonName, INPUT_PULLUP); // input with internal pullup, Button connects pin to Gnd when pressed.
}

And later

void loop(){
if (digitalRead(buttonName) == LOW){
// button has been pressed, do something
}
else {
// button  not pressed, do something else
}

}

Thanks.

I may actually have to print hat reply for future reference on the pin numbers.

No problem.

Ok, sorry, "next question":

About the 23017.

Got one! :)

An older project (alarm clock) I made a few years ago has ...... (maybe) a 23017 in it too. I can't get into the project to see but it is an I2C expander chip.

So......

28 pins. Woo Hoo!

To "use" it, I looked and downloaded a "23017 library". But then I thought that was strange, as I have used one in an earlier project and I didn't have a 23017 library already.

So I looked at that code and it uses the Centipede library.

Dumb question: Which one to use?

Are there an known advantages in either?

AFAIK the pins will be all OUTPUT.

Thanks again in advance.