distance sensor to midi cc

hi… i have to traduce tension or current (from the out of a distance sensor) to a midi signal.
i have to control a program’s parahm as a fader on ableton whit a distance sensor…
anyone can tell me how can i do this???

Try the map function

what is??? i don't know how to use arduino.. i need someone that can drive me step by step...or do it for me.. or someone that can tell me where to buy it...

Up there on the left is a link called 'Main Site.
There you'll find a reference section explaining the 'map' function, and the rest of the Arduino language

ok.. I've read map.. but i don't find anywhere which signal receive the analog imput of arduino...


ok thanx a lot!! so.. now.. once i've mapped my signal to a value from 0 to 255 how can i convert it in a sequential 8 bit number(like the midi)??

0..255 is an eight bit number

sure.. but.. i have to send that value to a midi instrument... like an ableton fader...

Did you look at any of the MIDI references over at the Playground?

i don't speech a good english so.. i didn't find anything about it...

do you know if this code help me??

// by Tubedogg 12/2006; fabian at tubedogg.de

//This program reads up to 6 analog sensors / potentiometers ans converts the data to Midi-Controller messages
// define Switchpin:
#define switchPin 10
//  define LED:
#define LEDpin 13

// Variables

// define variables for the controller data
int AnalogValue[6] = {0,0,0,0,0,0};    

// define the "lastValue" variables
int lastAnalogValue[6] = {0,0,0,0,0,0}; 
// select the midi Controller Number for each input
int midiCCselect[6] = {1,2,3,4,5,6};

// select threshold for each analog input  
int thresh[6] = {1,1,1,1,1,1};   

// select number of desired analog inputs (max 6)
int input_no = 6;

void setup() {
 //  set the states of the I/O pins:
 pinMode(switchPin, INPUT);
 pinMode(LEDpin, OUTPUT);
 //  Set MIDI baud rate:


// main program loop
void loop() {

for(int i=0;i<input_no;i++){

         AnalogValue[i] = (analogRead(i))/8;    // read the value from the analog input and divide by 8 for range 0-127
     // check if value is greater than defined threshold (good for resistive touchpads etc)
     if ( AnalogValue [i]>thresh[i] ) {
           // check if analog input has changed
           if ( AnalogValue[i] != lastAnalogValue[i] ) {

           //send control change on cc#i
           midiCC(0xB0, midiCCselect[i], AnalogValue[i]);
           // update lastAnalogValue variable
           lastAnalogValue[i] = AnalogValue[i];

           //End if
       //End if
//End for 

//End Loop

// This function sends a Midi CC. 
void midiCC(char CC_data, char c_num, char c_val){
 Serial.print(CC_data, BYTE);
 Serial.print(c_num, BYTE);
 Serial.print(c_val, BYTE);


Moderator edit: Reposted, sans italics.

do you know if this code help me??

Only you can answer that question.

do you know if this code help me??

it's well commented, seems like crystal clear code