Pages: [1]   Go Down
Author Topic: sending arduino data from multiple sensors to Pure Data  (Read 1161 times)
0 Members and 1 Guest are viewing this topic.
Ithaca, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am very new to this, so forgive my ignorance...

I am trying to send data from a force sensor and four flex sensors on an arduino uno to PD on my mac. I want to then translate the data into MIDI and DMX messages. I am stuck on getting the values routed properly in PD. Here is my arduino code:

====

int thumbForcePin = 4;
int indexFlexPin = 3;
int middleFlexPin = 2;
int ringFlexPin = 1;

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

void loop()

  delay(100);
  String data = "";
 
  int thumbval = analogRead(thumbForcePin);
  thumbval = constrain(thumbval, 320, 560);
  int thumblevel = map(thumbval, 320, 560, 127, 0);
  data = data + "[" + thumblevel + ";";

  int indexval = analogRead(indexFlexPin);
  indexval = constrain(indexval, 320, 560);
  int indexlevel = map(indexval, 320, 560, 127, 0);
  data = data + indexval + ";";

  int middleval = analogRead(middleFlexPin);
  middleval = constrain(middleval, 320, 560);
  int middlelevel = map(middleval, 320, 560, 127, 0);
  data = data + middlelevel + ";"; 

  int ringval = analogRead(ringFlexPin);
  ringval = constrain(ringval, 320, 560);
  int ringlevel = map(ringval, 320, 560, 127, 0);
  data = data + ringval + "]";

  Serial.print(data); 
}


I have been successful using comport to get the values from one sensor. But I'm not sure how to handle the list. I guess I am currently sending a string via Serial.print() ...does anyone know how to convert the data through comport so that I can unpack in Pure Data? Would I be better off using pduino or SMS? Thanks so much for any help!
Logged

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

Hi!! Have you figured out how to do that? I'm even newer than you and in a rush trying to fix my degree project. If you can please explain how you did that; it will be so highly appreciated!

Thanks,
Emin
Logged

Pages: [1]   Go Up
Jump to: