Hi,
For my first project on Arduino Nano, I would like to make an automatic counter of the number of ring presses on a wired intercom.
I want to be able to ring the bell on one of the three handsets depending on whether the bell button is pressed once, twice or three times at the entrance to the building: 1 press -> handset 1, 2 presses -> combined 2....
Does anyone know if this is doable with limited knowledge or have any advice to give?
Sure, first you'll have to provide a list of parts you have (or are considering), the circuit as you (at minimum) envision it, either schematic, hand drawing or very detailed description.
Post your code here. Don't forget code tags to make it easier to read. CTRL+T in the Arduino IDE will auto format your code.
Also, what you've tried, what worked and what didn't work.
Don't forget to use code tags.
To decouple the intercom from the Arduino, the use of an optocoupler is recommended.
The programme requires a timer module for debouncing of the input signal if needed and for monitoring the number of input pulses.
Here is a software design based on the IPO model:
INPUT: Debounce input
if (input goes high) counter++ and start timer PROCESSING: When the timer has expired, signal a new doorBellEvent OUTPUT: Execute doorBellEvent
You'll have to wait a bit after the first press to see if a second (or third) is on its way soon enough that you should ring two2 (or three3) instead of one1.
Can you now write a sketch that simply counts the number of times you have pressed a button, and prints the number each time it goes up?
Until you can do, you should work on that. It will necessarily drag you over some very basic issues, and coding techniques, involved with listening to buttons and reacting as you wish.
At least
button debouncing
state change (or "edge") detection
Both are covered all over the place, google and read a few articles on those sunjects, look also at the IDE examples code.
And trust me when I say nothing you learn on that side trip will be a waste of your time. In fact, just the opposite. You will have bnaked a key skill, which skill will be handy when you turn your attention back to the real goal.