You can use the rotary encoder ky-040 both to simulate a volume controller and to easily calculate The rotary encoder knob can be either turned or pressed; this way you have more possibilities for action The rotary encoder does not have a fixed final position; this way can be spun indefinitely the rotary encoder is perfect for your raspberry pi or arduino