I am working on a project using ATmega328 that requires waking up from sleep mode using button presses. Several articles explain how to do that by connecting the button to the interrupt line INT0 or INT1.
However I have 4 SPST buttons but only 2 interrupt lines. Each button needs to be able to wake the controller and as it wakes up the controller needs to know (e.g. by reading digital pins) which button was pressed.
The project is single battery operated so needs to be very energy efficient.
I am embedded SW eng', so I understand HW if explained slowly
Ok, I haven't tested it myself and am just thinking out loud. The Int Pins detect low or high but they Interpret anything lower than a certain voltage as a 0 and over that voltage as 1. Let's assume that the tip Point is 2.5 Volts. Both 1 Volts and 2 Volt are interpreted as a 0 and both 3 Volts and 4 Volts would be detected as a 1.
Now, the analog Pins can detect pretty Close to the true voltage. They can detect the difference between 1 Volt and 2 or 3 and 4.
Now, if we take two different resistors, tie one end of both high and the other end of each to a Switch. The other side of each Switch will also be connected to each other and then to ground. Now, depending on which Switch is pressed we would be able to read one of the two voltages at the Switch side.
If the Interrupt gets tripped when it goes high and we subsequently read the voltage, we should know which of the two Switches was pressed.
This takes care of two Buttons with just one Interrupt pin. Theoretically, it could be done for all four Buttons on a single Interrupt but the resistors would have to be high precision and tightly calculated.
Like I said, untested and just thinking out loud... Maybe also blowing smoke...