Pages: [1]   Go Down
Author Topic: distance sensor to midi cc  (Read 747 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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???
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26302
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try the map function
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26302
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26302
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

analogRead
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)??
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26302
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

0..255 is an eight bit number
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26302
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you look at any of the MIDI references over at the Playground?
http://arduino.cc/playground/Main/InterfacingWithHardware#Communication
« Last Edit: October 30, 2011, 04:04:19 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

do you know if this code help me??



Code:
// 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:
 Serial.begin(31250);

}

// 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.

« Last Edit: October 31, 2011, 02:38:49 am by AWOL » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26302
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do you know if this code help me??
Only you can answer that question.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

do you know if this code help me??
it's well commented, seems like crystal clear code
Logged

Pages: [1]   Go Up
Jump to: