# Making a Physical Fluxum, Part 2

A project log for Real World Fluxly, Physics Looper

A hardware implementation of Fluxly, a software musical physics looper in which you create new instruments by spinning colorful fluxum.

Now that the Fluxum controller and the Yak Shaver are talking to each other, the next step is to read the gyro sensor and send some actual data. I started with Kris Winer's MPU9250 example and added the Wifi and UDP broadcast code, this time calculating the angular velocity in degrees per second and sending that as four bytes. The gyro code hasn't been made into an Arduino library so the setup code is a little long to post here (it's in the files section). Here's the loop() code snippet:

```void loop() {

// If intPin goes high, all data registers have new data
if (readByte(MPU9250_ADDRESS, INT_STATUS) & 0x01) {  // On interrupt, check if data ready interrupt
getGres();

// Calculate the gyro value into actual degrees per second
gx = (float)gyroCount*gRes;  // get actual gyro value, this depends on scale being set
gy = (float)gyroCount*gRes;
gz = (float)gyroCount*gRes;

}

Now = micros();
deltat = ((Now - lastUpdate)/1000000.0f); // set integration time by time elapsed since last filter update
lastUpdate = Now;

sum += deltat; // sum for averaging filter update rate
sumCount++;

if (!AHRS) {
delt_t = millis() - count;
if(delt_t > 50) {
count = millis();
}
}

byte val1 = 0;
byte val2 = 0;
byte val3 = 0;
byte val4 = 0;
int v = abs(gz);

int thisVal = v;

if (!((thisVal < (prevVal + 2)) && (thisVal > (prevVal-2)) || (thisVal < 5)) && connected) {
//Send a packet
packetBuffer = command;
packetBuffer = dir;
if (thisVal < 5) val1 = 0;
packetBuffer = val1;
packetBuffer = val2;
packetBuffer = val3;
packetBuffer = val4;

udp.write(packetBuffer, 6);
udp.endPacket();
}

prevVal = thisVal;
delay(20);
}```

For the first iteration of this project I am only sending the absolute value of the z axis angular velocity. The next iteration will use the command field to indicate the direction of rotation so the sample can play forward or backward.

Here's the first working iteration of the Fluxum controller:

(Text from Richard Brautigan's All Watched Over By Machines of Loving Grace, copyleft 1967 by author):

...I like to think
of a cybernetic forest
filled with pines
and electronics
where deer roam peacefully
past computers
as if they were flowers
with spinning blossoms

Next steps:

• Play samples forward and backward
• Make custom PCB with 3 evenly spaced AA batteries for more of a flywheel effect
• RGB LEDs to backlight Fluxum character
• Use ESP32 streaming audio example to play sound on the actual device instead of the server

## Discussions 