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......
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.
(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.
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.
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
}
}
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.