Soziale Architektur 1 4Jhg

Aus hyperdramatik
Zur Navigation springen Zur Suche springen

BNO055 for esp32: wiring and advanced Bosch library:

D22 --- SCL

D21 --- SDA

https://mischianti.org/bno055-for-esp32-esp8266-and-arduino-wiring-and-advanced-bosch-library-2/


ESP-NOW with ESP32: Receive Data from Multiple Boards (many-to-one):

https://randomnerdtutorials.com/esp-now-many-to-one-esp32/

Arduino Get MAC Address CODE

/*
  Rui Santos & Sara Santos - Random Nerd Tutorials
  Complete project details at https://RandomNerdTutorials.com/get-change-esp32-esp8266-mac-address-arduino/
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
#ifdef ESP32
  #include <WiFi.h>
  #include <esp_wifi.h>
#else
  #include <ESP8266WiFi.h>
#endif

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

  Serial.print("ESP Board MAC Address: ");
  #ifdef ESP32
    WiFi.mode(WIFI_STA);
    WiFi.STA.begin();
    uint8_t baseMac[6];
    esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac);
    if (ret == ESP_OK) {
      Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
                    baseMac[0], baseMac[1], baseMac[2],
                    baseMac[3], baseMac[4], baseMac[5]);
    } else {
      Serial.println("Failed to read MAC address");
    }
  #else
    Serial.println(WiFi.macAddress());
  #endif
}
 
void loop(){

}

Arduino Send CODE

/*********
  Rui Santos & Sara Santos - Random Nerd Tutorials
  Complete project details at https://RandomNerdTutorials.com/esp-now-many-to-one-esp32/
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

  CIRCUIT
  ESP32:
  SCL (default is GPIO 22) 
  SDA (default is GPIO 21)
  D21 -- SDA
  D22 -- SCL
*********/
#include <esp_now.h>
#include <WiFi.h>

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>


/* Set the delay between fresh samples */
#define BNO055_SAMPLERATE_DELAY_MS 200

// Check I2C device address and correct line below (by default address is 0x29 or 0x28)
//                                   id, address
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28);


// REPLACE WITH THE RECEIVER'S MAC Address
//uint8_t broadcastAddress[] = { 0x78, 0x21, 0x84, 0x9a, 0x5c, 0x0c };  //78:21:84:9a:5c:0c = rALL
//uint8_t broadcastAddress[] = { 0x78, 0x21, 0x84, 0x9a, 0xa6, 0x08 };  // 78:21:84:9a:a6:08 = r1 PINK
//uint8_t broadcastAddress[] = { 0x08, 0x3a, 0xf2, 0xb6, 0x8b, 0x74 };  // 08:3a:f2:b6:8b:74 = r2 PINK
uint8_t broadcastAddress[] = { 0x7c, 0x9e, 0xbd, 0xf8, 0xf2, 0xc8 }; //7c:9e:bd:f8:f2:c8
//uint8_t broadcastAddress[] = { 0x78, 0x21, 0x84, 0x9b, 0x15, 0x51 };  // 78:21:84:9b:15:51 = r3 PINK

/*
r1 PINK - 78:21:84:9a:a6:08
s1 PINK - 78:21:84:7e:cd:85
s2 PINK - 08:3a:f2:71:98:99
r2 PINK - 08:3a:f2:b6:8b:75
r3 PINK - 78:21:84:9b:15:51
s3 PINK - 08:3a:f2:71:8a:81
*/


// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
  int id;  // must be unique for each sender board
  int x;
  int y;
  int z;
} struct_message;

// Create a struct_message called myData
struct_message myData;

// Create peer interface
esp_now_peer_info_t peerInfo;

// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nLast Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}


void setup() {
  // Init Serial Monitor
  Serial.begin(9600);

  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);

  // Register peer
  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;
  peerInfo.encrypt = false;

  // Add peer
  if (esp_now_add_peer(&peerInfo) != ESP_OK) {
    Serial.println("Failed to add peer");
    return;
  }

  Serial.println("Orientation Sensor Test");
  Serial.println("");

  /* Initialise the sensor */
  if (!bno.begin()) {
    /* There was a problem detecting the BNO055 ... check your connections */
    //Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    /*
      // Set values to send
  myData.id = 1;
  myData.x = 111;
  myData.y = 111;
  myData.z = 111;

  // Send message via ESP-NOW
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&myData, sizeof(myData));
  */
    //while (1);
  }

  delay(1000);

  /* Use external crystal for better accuracy */
  bno.setExtCrystalUse(true);

  /* Display some basic information on this sensor */
  //displaySensorDetails();
}


void loop() {
  /* Get a new sensor event */
  sensors_event_t event;
  bno.getEvent(&event);

  // Store data in varabiles x,y,z
  int x = event.orientation.x;
  int y = event.orientation.y;
  int z = event.orientation.z;

  // Print values to check
  Serial.print(x);
  Serial.print("\t");
  Serial.print(y);
  Serial.print("\t");
  Serial.println(z);

  // Set values to send
  myData.id = 1;
  myData.x = x;
  myData.y = y;
  myData.z = z;

  // Send message via ESP-NOW
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&myData, sizeof(myData));

  if (result == ESP_OK) {
    //Serial.println("Sent with success");
  } else {
    //Serial.println("Error sending the data");
  }

  delay(BNO055_SAMPLERATE_DELAY_MS);
}


void printCallibration() {
  /* Also send calibration data for each sensor. */
  uint8_t sys, gyro, accel, mag = 0;
  bno.getCalibration(&sys, &gyro, &accel, &mag);
  Serial.print(F("Calibration: "));
  Serial.print(sys, DEC);
  Serial.print(F(" "));
  Serial.print(gyro, DEC);
  Serial.print(F(" "));
  Serial.print(accel, DEC);
  Serial.print(F(" "));
  Serial.println(mag, DEC);
}


Arduino Receive CODE

/*********
  Rui Santos & Sara Santos - Random Nerd Tutorials
  Complete project details at https://RandomNerdTutorials.com/esp-now-many-to-one-esp32/
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*********/

#include <esp_now.h>
#include <WiFi.h>

// Structure example to receive data
// Must match the sender structure!
typedef struct struct_message {
  int id;
  int x;
  int y;
  int z;
} struct_message;

// Create a struct_message called myData
struct_message myData;

// Create a structure to hold the readings from each board
struct_message board1;
struct_message board2;
struct_message board3;
struct_message board4;

// Create an array with all the structures
struct_message boardsStruct[4] = { board1, board2, board3, board4 };

// callback function that will be executed when data is received
// IMPORTANT: keepe this function above the setup()!
void OnDataRecv(const uint8_t *mac_addr, const uint8_t *incomingData, int len) {

  memcpy(&myData, incomingData, sizeof(myData));  // get the incoming data
  // Update the structures with the new incoming data:
  boardsStruct[myData.id - 1].x = myData.x;
  boardsStruct[myData.id - 1].y = myData.y;
  boardsStruct[myData.id - 1].z = myData.z;
  // Store the data in x,y,z variables:
  int id = myData.id;
  int x = boardsStruct[myData.id - 1].x;
  int y = boardsStruct[myData.id - 1].y;
  int z = boardsStruct[myData.id - 1].z;
  // Print the data to the Serial Port:
  Serial.print(id);
  Serial.print("\t");
  Serial.print(x);
  Serial.print("\t");
  Serial.print(y);
  Serial.print("\t");
  Serial.println(z);
}

void setup() {
  Serial.begin(9600); //Initialize Serial Monitor
  WiFi.mode(WIFI_STA);  //Set device as a Wi-Fi Station

  //Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  // Once ESPNow is successfully Init, we will register for recv CB to get recv packer info
  esp_now_register_recv_cb(esp_now_recv_cb_t(OnDataRecv));
}

void loop() {
  // Nothing happens in the loop because it all happens in OnDataRecv 
}


Processing Sound CODE (frequency)

/*
 Spiel und Objekt + Choreographie
 Soziale Architektur WiSw 2024/25
 by hannah perner-wilson
 
 this code:
 reads a string of sensor values from arduino
 splits this string into individual sensor values
 visualizes each sensor value as a knob
 the sensor values control the frequency of a sound wave
 if the sensor is moving, the amplitude (volume) of this sound wave increases
 if the sensor is NOT moving, the amplitude (volume) of this sound wave decreases and becomes silent
 */

/*
//Pitch, yaw and roll are the three dimensions of movement when an object moves through a medium
 --1 = Yaw_____nose moves from side to side (“compass”)
 --2 = Pitch___nose up or tail up
 --3 = Roll____nose twists clockwise or anti-clockwise
 */

///////////////////////////////////////
/////YOU CAN MODIFY THESE VALUES://////
///////////////////////////////////////

int module_one =   3;  //1=yaw, 2=pitch, 3=roll
int module_two =   3;  //1=yaw, 2=pitch, 3=roll
int module_three = 3;  //1=yaw, 2=pitch, 3=roll
int module_four =  3;  //1=yaw, 2=pitch, 3=roll

int interval = 100;  // check for change at this interval
float volumeSteps = 0.05;  // change volume in this step

int freqMIN = 0;
int freqMAX = 100;

//////////////////////////////////////
//////////////////////////////////////

import processing.serial.*;
import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.signals.*;

Minim minim;
Oscil wave1;
Oscil wave2;
Oscil wave3;
Oscil wave4;
AudioOutput out;
Summer sum = new Summer();

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph
float inByte = 0;
int[] incomingValues = {1, 0, 0, 0};
float amp[] = new float[4];
float freq[] = new float[4];

int previousMillis[] = new int[4];
int value[] = new int[4];
int pValue[] = new int[4];
int[] activeSensors = {module_one, module_two, module_three, module_four};

void setup () {
  size(1000, 600);
  //size(2400, 1450);
  ellipseMode(CENTER);

  printArray(Serial.list());  //prints a list of the available serial ports
  //myPort = new Serial(this, Serial.list()[2], 9600);
  myPort = new Serial(this, "/dev/tty.usbserial-0001", 9600);
  
  //myPort = new Serial(this, "COM3", 9600);
  myPort.bufferUntil('\n');  // don't generate a serialEvent() unless you get a newline character

  minim = new Minim(this);
  out = minim.getLineOut(Minim.STEREO);  // use the getLineOut method of the Minim object to get an AudioOutput object

  // create some Oscils to patch to the Summer:
  wave1 = new Oscil( Frequency.ofPitch("A4"), 0, Waves.SQUARE );
  wave1.patch( sum );  // patch the Oscil to the Summer
  wave2 = new Oscil( Frequency.ofPitch("C#5"), 0, Waves.SINE );
  wave2.patch( sum );
  wave3 = new Oscil( Frequency.ofPitch("E5"), 0, Waves.TRIANGLE );
  wave3.patch( sum );
  wave4 = new Oscil( Frequency.ofPitch("E5"), 0, Waves.SINE );
  wave4.patch( sum );
  sum.patch( out );// and the Summer to the output and you should hear a major chord
}







void draw () {
  
  //fill(255);

  drawWaveform();

  ///////////////////////
  //PARSE SENSOR VALUES//
  ///////////////////////
  if(incomingValues[0] == 0) incomingValues[0] = 1;
  
  for (int i = 0; i < 4; i++) {
    if (millis() - previousMillis[incomingValues[0]-1] >= interval) {
      previousMillis[incomingValues[0]-1] = millis();    // Update the previousMillis to current time
      value[incomingValues[0]-1] = incomingValues[activeSensors[i]];

      if (value[incomingValues[0]-1] == pValue[incomingValues[0]-1]) {
        amp[incomingValues[0]-1] = amp[incomingValues[0]-1] - volumeSteps;
        if (amp[incomingValues[0]-1] < 0) amp[incomingValues[0]-1] = 0;
      } else {
        amp[incomingValues[0]-1] = amp[incomingValues[0]-1] + volumeSteps;
        if (amp[incomingValues[0]-1] > 1) amp[incomingValues[0]-1] = 1;
      }
      pValue[incomingValues[0]-1] = value[incomingValues[0]-1];
    }
    freq[i] = map(incomingValues[activeSensors[i]], 0, 360, freqMIN, freqMAX);
    freq[i] = constrain(freq[i], freqMIN, freqMAX);

    println("#" + incomingValues[0] + "\t" + "freq:" + freq[incomingValues[0]-1] + "\t" + "amp:" + amp[incomingValues[0]-1] + "\t" + "value:" + value[incomingValues[0]-1] + "\t" + "pValue:" + pValue[incomingValues[0]-1]);
  }
  if (incomingValues[0] == 1) {
    wave1.setAmplitude( amp[incomingValues[0]-1] );
    wave1.setFrequency( freq[incomingValues[0]-1] );
    sensorVis(activeSensors[0]);
  }
  if (incomingValues[0] == 2) {
    wave2.setAmplitude( amp[incomingValues[0]-1] );
    wave2.setFrequency( freq[incomingValues[0]-1] );
    sensorVis(activeSensors[1]);
  }
  if (incomingValues[0] == 3) {
    wave3.setAmplitude( amp[incomingValues[0]-1] );
    wave3.setFrequency( freq[incomingValues[0]-1] );
    sensorVis(activeSensors[2]);
  }
  if (incomingValues[0] == 4) {
    wave4.setAmplitude( amp[incomingValues[0]-1] );
    wave4.setFrequency( freq[incomingValues[0]-1] );
    sensorVis(activeSensors[3]);
  }
}



////////////////////////
//SENSOR VISUALISATION//
////////////////////////
void sensorVis(int activeSensor) {
  
  noFill();
  for (int i = 1; i<4; i++) {
    float rotateMe = map(incomingValues[i], 0, 360, 0, 6.28);
    
    pushMatrix();
    translate(incomingValues[0] * width/5, height - i*height/6);
    rotate(rotateMe);
    if (i == activeSensor) stroke(200, 0, 0);
    else stroke(255);
    strokeWeight(6);
    line(0, 0, 0, 50);
    strokeWeight(1);
    ellipse(0, 0, 50, 50);
    popMatrix();
  }
}



////////////////////////////
//SOUND WAVE VISUALISATION//
////////////////////////////
void drawWaveform() {
  background(0);
  stroke(255);
  strokeWeight(1);

  // draw the waveform of the output
  for (int i = 0; i < out.bufferSize() - 1; i++)
  {
    //scale(0.1);
    line( i, 50  - out.left.get(i)*50, i+1, 50  - out.left.get(i+1)*50 );
    line( i, 150 - out.right.get(i)*50, i+1, 150 - out.right.get(i+1)*50 );
  }

  // draw the waveform we are using in the oscillator
  stroke( 128, 0, 0 );
  strokeWeight(4);
  for ( int i = 0; i < width-1; ++i )
  {
    point( i, height/2 - (height*0.49) * wave1.getWaveform().value( (float)i / width ) );
  }
}


////////////////////
//CHANGE WAVE FORM//
////////////////////
void keyPressed()
{
  switch( key )
  {
  case '1':
    wave1.setWaveform( Waves.SINE );
    wave2.setWaveform( Waves.SINE );
    wave3.setWaveform( Waves.SINE );
    wave4.setWaveform( Waves.SINE );
    break;

  case '2':
    wave1.setWaveform( Waves.TRIANGLE );
    wave2.setWaveform( Waves.TRIANGLE );
    wave3.setWaveform( Waves.TRIANGLE );
    wave4.setWaveform( Waves.TRIANGLE );
    break;

  case '3':
    wave1.setWaveform( Waves.SAW );
    wave2.setWaveform( Waves.SAW );
    wave3.setWaveform( Waves.SAW );
    wave4.setWaveform( Waves.SAW );
    break;

  case '4':
    wave1.setWaveform( Waves.SQUARE );
    wave2.setWaveform( Waves.SQUARE );
    wave3.setWaveform( Waves.SQUARE );
    wave4.setWaveform( Waves.SQUARE );
    break;

  case '5':
    wave1.setWaveform( Waves.QUARTERPULSE );
    wave2.setWaveform( Waves.QUARTERPULSE );
    wave3.setWaveform( Waves.QUARTERPULSE );
    wave4.setWaveform( Waves.QUARTERPULSE );
    break;

  default:
    break;
  }
}


////////////////
//SERIAL INPUT//
////////////////
void serialEvent (Serial myPort) {
  //String inString = myPort.readStringUntil('\n');  // get the ASCII string
  String inString = myPort.readStringUntil('\n');
  //println(inString);

  if (inString != null) {  // if it's not empty
    inString = trim(inString);  // trim off any whitespace
    incomingValues = int(split(inString, "\t"));  // convert to an array of ints

    // print the values to see:
    for (int count = 0; count < incomingValues.length; count++) {
      //println("incomingValue " + count + " : " + incomingValues[count]);  // print values to see
    }
  }
  myPort.clear();
}


Processing Sound CODE (play file)

/*
 Spiel und Objekt + Choreographie
 Soziale Architektur WiSw 2024/25
 by hannah perner-wilson
 
 this code:
 reads a string of sensor values from arduino
 splits this string into individual sensor values
 visualizes each sensor value as a knob
 movement triggers random soundfiles to play
 */

/*
//Pitch, yaw and roll are the three dimensions of movement when an object moves through a medium
 --1 = Yaw_____nose moves from side to side (“compass”)
 --2 = Pitch___nose up or tail up
 --3 = Roll____nose twists clockwise or anti-clockwise
 */

///////////////////////////////////////
/////YOU CAN MODIFY THESE VALUES://////
///////////////////////////////////////

//which sensor is active:
int activeSensor = 1;  //1=yaw, 2=pitch, 3=roll

//how sensitive is it to movement (the lower the number the more sensitive)
int sensitivity = 2;

//how long does it take to get loud and go silent:
float volumeSteps = 15;  // the larger the number, the faster it will change volume (get louder and quieter)

//////////////////////////////////////
//////////////////////////////////////

import processing.serial.*;
import ddf.minim.*;

Minim minim;
AudioPlayer player;
int numberSounds = 9;
AudioPlayer[] playlist = new AudioPlayer[numberSounds];

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph
float inByte = 0;
//int[] incomingValues = {1, 0, 0, 0};
int[] incomingValues = new int[4];

int interval = 200;  // check for change at this interval
int previousMillis;
int value;
int pValue;
float volume;
int number = 0;
int randomPlay;

/////////////////////////////// <<< SETUP >>> //////////////////////////////////////

void setup () {
  size(1000, 600, P2D);
  //size(2400, 1450);
  ellipseMode(CENTER);

  printArray(Serial.list());  //prints a list of the available serial ports
  //myPort = new Serial(this, Serial.list()[1], 9600);
  myPort = new Serial(this, "COM3", 9600);
  myPort.bufferUntil('\n');  // don't generate a serialEvent() unless you get a newline character

  minim = new Minim(this);

  playlist[0] = minim.loadFile("1.wav");
  playlist[1] = minim.loadFile("2.wav");
  playlist[2] = minim.loadFile("3.wav");
  playlist[3] = minim.loadFile("4.wav");
  playlist[4] = minim.loadFile("5.wav");
  playlist[5] = minim.loadFile("6.wav");
  playlist[6] = minim.loadFile("7.wav");
  playlist[7] = minim.loadFile("8.wav");
  playlist[8] = minim.loadFile("9.wav");

  randomPlay = int(random(0, numberSounds-2));
  playlist[randomPlay].play();
}



/////////////////////////////// <<< DRAW >>> //////////////////////////////////////

void draw () {
  
  //////////////////////
  //PLAY RANDOM SOUNDS//
  //////////////////////
  playlist[randomPlay].setGain(volume);

  if ( playlist[randomPlay].position() == playlist[randomPlay].length() )
  {
    playlist[randomPlay].rewind();
    randomPlay = int(random(0, numberSounds-2));
    playlist[randomPlay].play();
  }

  playlist[number].play();


  //////////////////////////////////
  //CHECK MOVEMENT & ADJUST VOLUME//
  //////////////////////////////////
  if (millis() - previousMillis >= interval) {
    previousMillis = millis();    // Update the previousMillis to current time
    value = incomingValues[activeSensor];

    if (abs(value-pValue) < sensitivity) {
      //if (value == pValue) {
      //print("NO movement");
      volume = volume - volumeSteps;
      if (volume < -60) volume = -60;
    } else {
      //print("YES movement!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      volume = volume + volumeSteps;
      if (volume > 60) volume = 60;
    }
    
    pValue = value;
  }
  
  println("\t" + "sensorValue: " + incomingValues[activeSensor] + "\t" + "volume: " + volume + "\t" + "random: " + randomPlay);


  drawWaveform(number);
  sensorVis(activeSensor);
}



////////////////////////
//SENSOR VISUALISATION//
////////////////////////
void sensorVis(int myActiveSensor) {
  background(0);
  noFill();
  for (int i = 1; i<4; i++) {
    float rotateMe = map(incomingValues[i], 0, 360, 0, 6.28);

    pushMatrix();
    translate(incomingValues[0] * width/5, height - i*height/6);
    rotate(rotateMe);
    if (i == myActiveSensor) stroke(200, 0, 0);
    else stroke(255);
    strokeWeight(6);
    line(0, 0, 0, 50);
    strokeWeight(1);
    ellipse(0, 0, 50, 50);
    popMatrix();
  }
}



////////////////////////////
//SOUND WAVE VISUALISATION//
////////////////////////////
void drawWaveform(int number) {
  background(0);
  stroke(255);

  // draw the waveforms
  // the values returned by left.get() and right.get() will be between -1 and 1,
  // so we need to scale them up to see the waveform
  // note that if the file is MONO, left.get() and right.get() will return the same value
  for (int i = 0; i < playlist[number].bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, playlist[number].bufferSize(), 0, width );
    float x2 = map( i+1, 0, playlist[number].bufferSize(), 0, width );
    line( x1, 50 + playlist[number].left.get(i)*50, x2, 50 + playlist[number].left.get(i+1)*50 );
    line( x1, 150 + playlist[number].right.get(i)*50, x2, 150 + playlist[number].right.get(i+1)*50 );
  }

  // draw a line to show where in the song playback is currently located
  float posx = map(playlist[number].position(), 0, playlist[number].length(), 0, width);
  stroke(0, 200, 0);
  line(posx, 0, posx, height);
}





////////////////////
//TRIGGER FILE//
////////////////////
void keyPressed()
{
  playlist[numberSounds-1].setGain(60);
  playlist[numberSounds-1].play();
  if ( playlist[numberSounds-1].position() == playlist[numberSounds-1].length() )
  {
    playlist[numberSounds-1].rewind();
  }
}



////////////////
//SERIAL INPUT//
////////////////

int[] incomingValues = new int[];

void serialEvent (Serial myPort) {
  //String inString = myPort.readStringUntil('\n');  // get the ASCII string
  String inString = myPort.readStringUntil('\n');
  //println(inString);

  if (inString != null) {  // if it's not empty
    inString = trim(inString);  // trim off any whitespace
    incomingValues = int(split(inString, "\t"));  // convert to an array of ints

   float freq = incomingValues[0];
   float volume = incomingValues[1];
   
   println("frequency: " + freq + "\t" + "volume: " + volume);
   
  myPort.clear();
}