Page 1 of 1

Posted: 02 Feb 2016, 17:19
by joffo78
Hello
I need to build a little basic trigger with 8 possibilities (buttons or knob) that could be hide on a wardrobe.
I think to make in with arduino. I manage to find a code (on the wiki page) to receive one value with the serial module in usine.
But it seems to me more complex if i'd like to receive several values on the same time.
Any experience ?
Thanks
JF

Posted: 03 Feb 2016, 07:30
by rlgsbt
Hi,
You can use the fonction "map" to split the analog inputs.

Code: Select all

void loop() {
  // read the input on analog pin 0:
  int sensor1Value = analogRead(A0);
  // print out the value you read:
  Serial.println(sensor1Value);
  delay(10);        // delay in between reads for stability
  
    // read the input on analog pin 1:
  int sensor2Value = analogRead(A1);
  // transform values from 0-1023 to 2000-3023 
  sensor2Value = map(sensor2Value, 0, 1023, 2000, 3023);
  // print out the value you read:
  Serial.println(sensor2Value);
  delay(10);        // delay in between reads for stability
  
      // read the input on analog pin 2:
  int sensor3Value = analogRead(A2);
  sensor3Value = map(sensor3Value, 0, 1023, 4000, 5023);
  // print out the value you read:
  Serial.println(sensor3Value);
  delay(10);        // delay in between reads for stability
then in Usine, all datas between 0-1023 are coming from A0, datas between 2000-3023 are coming from A1, etc.
SB

Posted: 04 Feb 2016, 10:33
by oli_lab
you can as well use a Teensy in USBMIDI, more straigth forward than comport IMHO

Olivar