Go Down

Topic: midi controller (Read 98 times) previous topic - next topic

camilozk

Hi!

I have just done this sketch for a midi controller

I am using just one potentiometer, and I have checked that it works. I wanted to anyway post the code here and see if someone has some advice - suggestion in order to improve the code

:)

Code: [Select]
unsigned char status;
#define midichannel 0;

int sensorValue01;


void setup() {
  Serial.begin(31250);
}

void loop() {
     
  sensorValue01 = analogRead(A0);
  int ccvalue = map(sensorValue01, 0, 1023, 0, 127);
  MIDI_TX(176,0,ccvalue);
}

//*******************************************************************************************************************
// Transmit MIDI Message
//*******************************************************************************************************************
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
  status = MESSAGE + midichannel;
  Serial.write(status);
  Serial.write(PITCH);
  Serial.write(VELOCITY);
}

Go Up