Page 1 of 1
Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Wed Jul 08, 2026 6:25 pm
by andeug
Hi,
I am working on a project with an Arduino Uno, a Mikroe Arduino Uno Click Shield, a Mikroe 7seg Click, and a Mikroe Analog Key Click.

- IMG_0688.jpeg (100.71 KiB) Viewed 262 times
The project should read each button press from the Mikroe Analog Key Click and display its value on the 2nd digit of a 7-segment display; when no button is pressed, the 2nd digit should remain blank.
I have measured with a Fluke calibrated multimeter the values of VOUT (AN) from OPA344NA, and they look as follows:
Button 1 press = 3,27V
Button 2 press = 2,73V
Button 3 press = 2,18V
Button 4 press = 1,63V
Button 5 press = 1,09V
Button 6 press = 0,54V
What I need is a safe mechanism that can determine whether, if I have a VOUT voltage between 3.2V and 3.3V (not the exact value), button 1 is pressed. The same follows for the other buttons. When 0V is measured, nothing is displayed on the 7-segment display.
I don't think that this is how the flow code should be made... Can someone please help me figure out how to make this small project work?
Regards,
Andreas
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Wed Jul 08, 2026 7:58 pm
by medelec35
Hello.
GetVoltage requires a float variable, you have got it as an int.
Therefore Voltage will be ints only so no good if you want to check to say 2.3V
You will need to change the Voltage variable to a Float.
With the Decision branches, using just If:Voltage , then every time the voltage is 1V or higher it will be true.
What you will need is If: (Voltage >= 3.2) && (Voltage <= 3.3) to add the hysteresis.
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Wed Jul 08, 2026 8:52 pm
by andeug
Hi,
I have made the changes per your instructions, but the flow code still does not work...
Maybe this isn't the way it should be done?
Andreas
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Wed Jul 08, 2026 11:42 pm
by medelec35
I have modified your project so voltage ranged can be detected.
I'm not sure why you want to show segments rather than digits but you know what you want lol.
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Thu Jul 09, 2026 7:54 am
by andeug
Thank you for your help, Martin! I have tested the code you gave me, and it works perfectly on my hardware.
Since I have a limited number of I/Os on the Arduino Uno, I will use the Analog Key Click schematic because it requires only one analog input on the ATmega328, allowing me to have 6 different keys.
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Thu Jul 09, 2026 9:26 am
by medelec35
You're welcome.
I'm glad your project is now working as expected.
You can also nest the decision branches and then in the final no branch will be accessed if all the condition are false.ts
Its the C equivalent to a chain of if / else if / else if / ... / else, rather than a series of separate if statements.
E.g if voltage is <0.7 or >3.4.
I would also recommend using a small delay within the main loop.
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Thu Jul 09, 2026 1:34 pm
by andeug
Hi,
I have tested your new proposal, and it has been working better than mine. Mine was ghosting some segments after I stopped pressing any buttons, possibly indicating a debouncing issue, but then I realized it disappeared after I added a 100ms delay before the end of the loop. That solved my problem, as you have said in your message.
The schematic of the Mikroe Analog Key Click is optimal for my use case, as I want to use only one analog input for my clock. Even if I press the buttons simultaneously, I do not get any other command than the one for the buttons I have pressed.
Andreas
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Posted: Thu Jul 09, 2026 2:07 pm
by medelec35
I'm glad its working even better for you now.
I did have a thought about simulation.
When I created the Potentiometer component, I added the option to display whatever type of read value is used.
E.g GetVoltage you will see the voltage value underneath.

- option3.png (50.36 KiB) Viewed 134 times
GetByte the 0 to 255 will be displayed.

- Option4.png (102.27 KiB) Viewed 134 times
GetInt then 0 to 1023 will be displayed etc.
You can add above the GetVoltage a GetByte.
Then single step using F8 to step into each function/icon.
For beginners - red star means component or icon added but project not saved,