Mapin Thumbstick midi

Hi guys, Wanted to ask how to map midi to this basic thumbstick/joystic code (so it could be used with MAX/MSP)?

// Arduino pin numbers
const int SW_pin = 2; // digital pin connected to switch output
const int X_pin = 0; // analog pin connected to X output
const int Y_pin = 1; // analog pin connected to Y output

void setup() {
  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  Serial.begin(115200);
}

void loop() {
  Serial.print("Switch:  ");
  Serial.print(digitalRead(SW_pin));
  Serial.print("\n");
  Serial.print("X-axis: ");
  Serial.print(analogRead(X_pin));
  Serial.print("\n");
  Serial.print("Y-axis: ");
  Serial.println(analogRead(Y_pin));
  Serial.print("\n\n");

Well I guess the first thing is to define what MIDI messages you want it to send and when it should send them. There are lots of MIDI programs around and they all start with knowing what it is they want to do.

Steve