Potentiometer triggers button and other way around

Hi! I am quite new in electronics and I have issue.
I am doing custom keyboard using arduino micro and potentiometer with switches.
I was following guides and all was good when I was tested separately. When I make it working together, turning pot also triggers buttons clicks (sometimes keyboard prints pressed). And other way around, button click also triggers pot value changes (I get down, pressed, up).

I don't use any additional resistors (should I?). Connection is very simple. Button connected to ground and pin 42. Pot connected to 5v, ground and pin 41. I will attach schematics below.

I assume this happens because voltage drops down or something. I am using type-c connector, it should be enough power for arduino, I guess.

Maybe something wrong with my logic. I added delay to button to avoid fluctuations. Will add a capacitor and remove this delay. Maybe this is the problem?
Posting code here.

Thank you in advance for help!

#include <math.h>
#include <Keyboard.h>

#define PORT_POTENTIOMETER 41
#define PORT_BUTTON 42
#define LIMIT 50

// Keyboard
void mute();
void quit();
void raise();

// Volume
void volume_up();
void volume_down();

// Controllers
void read_button();
void read_rotary();

// Main
void setup() {
	pinMode(PORT_BUTTON, INPUT_PULLUP);
	Keyboard.begin();
}

void loop() {
	read_button();
	read_rotary();
}

// Implementations

int is_low = 1;
void read_button() {
	int state = digitalRead(PORT_BUTTON);
	if (is_low && state == HIGH) {
		Keyboard.print("pressed\n");
	}
	is_low = state == LOW;
	delay(100);
}

char current = 0;

void read_rotary() {
	char value = analogRead(PORT_POTENTIOMETER);
 	char diff = value - current;
	if (abs(diff) <= LIMIT) {
		return;
	}
	if (diff > 0) {
		volume_up();
	} else {
		volume_down();
	}
	current = value;
}

void mute() {
	Keyboard.print("mute\n");
//	Keyboard.press('D');
//	Keyboard.press(KEY_LEFT_CTRL);
//	Keyboard.releaseAll();
}

void raise() {
	Keyboard.print("raise\n");
//	Keyboard.press(KEY_LEFT_CTRL);
//	Keyboard.press(KEY_LEFT_GUI);
//	Keyboard.press('H');
//	Keyboard.releaseAll();
}

void quit() {
	Keyboard.print("quit\n");
//	Keyboard.press(KEY_LEFT_CTRL);
//	Keyboard.press('W');
//	Keyboard.releaseAll();
}

void volume_up() {
	Keyboard.print("up\n");
//	Keyboard.press(KEY_RIGHT_GUI);
//	Keyboard.press(KEY_F10);
//	Keyboard.releaseAll();
}

void volume_down() {
	Keyboard.print("down\n");
// 	Keyboard.press(KEY_RIGHT_GUI);
// 	Keyboard.press(KEY_F9);	
// 	Keyboard.releaseAll();
}

Syntax !

Thanks for reply. Should be this?

if (state == LOW) {
    is_low = 1;
} else {
    is_low = 0;
}

It's still not clear why clicking button affects potentiometer.

UPD: I changed this part, but still have same problem.

Let's use integer (int) :wink:

Sure. :blush: I thought I will save some memory. Thank you for quick response. I will check it out now.

I changed to int, but problem still exist. But I found something interesting.
If I put pot to the minimum, button produces up, pressed, down
If I put pot to the medium position, button stop producing pressed
If I put pot to the maximum, clicking button doesn't have any effect.

So behavior depends on the resistance of pot, must be electronics. Any ideas?

I will try another button and also will add capacitor here, but this all looks weird.
Should I also try to pull up with external resistor?
Potentiomenter and button are connected with jumpers right to pins of the arduino, I don't use whiteboard.

Potentiometer produces pressed even if button is disconnected :hushed: