Potentiometer velocity limit to 100 (1-100)

Hi,

I made a simple midi controller with one button and a potentiometer.
My question is: how can I limit the potentiometer velocity to 100 instead of default 127?

The sketch:

#include <MIDI_Controller.h> // This lets the microcontroller speak "MIDI"

const uint8_t velocity = 0b1111111; // This sets default velocity to 100% (127 value)
const uint8_t C4 = 60; // Name the note you want to play when the button is pushed(can be anything, C3...D5...E2)

Digital button1(2, C4, 1, velocity); // Format is this: button[number] (pin, note, channel, velocity)

Analog potentiometer1(A0, MIDI_CC::Channel_Volume, 1);

Thanks!

You forget to

  • Mention (and link!) the library you use
  • To post compilable code :wink:

But I looked up the library (did you as well?) and you can add a map-function to your Analog object

int potLimit100(int n){
  return map(n, 0, 1024, 0, 101);
}

potentiometer1.map(potLimit100);

PS If you start numbering variables (including objects like Analog) it's time to use arrays :wink:

Sorry about the things that I forgot to write, but thanks for the code, it works :wink: