November 8: Project Update

Nov 07, 2021 11:44PM

Code x Debug: Bluetooth

Because the docs and resources I was looking into were from the arduino nano, I eventually realized that the library would not wwork on the Circuit Playground. To move forwward, I tried to recreate my previous prototype on the Arduino Nano. Additionally, I tried to figure out howw to make bluetooth work with the Circuit Playground.

Beyond this, I ran into errors on the p5/browser end attempting to connect to the Nano. I ended up getting errors about permissions and iframes.

Failure: Bluetooth x Circuit Playground

The Circuit Playground seems to have more bluetooth support for Circuit Python as opposed to arduino. I was able to find code for using it as a peripheral, but the code seems to be build in and not entirely customizable. I found a code that allowed the CP to become a beacon, but couldn’t find similar features to what the Arduino Bluetooth Library had (code that allowed you to declare Services and Characteristics.) So while my computer could connect to the Circuit playground, I could not figure out how to pass data around.

It was also odd that there was no place in the example code for a UUID; which I believe is needed for p5 to identify your device. Adafruit’s documentation contained info on it; however it became unclear to me if the errors I was recieving was due to bugs in p5 or Arduino.

Arduino Nano x Prototype Attempt

I realized that because Arduino Nano Bluetooth docs are better and that the board not only had an accelerometer, but also had a gyroscope and a magnetometer, I was more inclined to make use of it for my project. I dove into researchign about IMUs (inertial measurement units) and tried and struggled to make sense of accelerometer and gyroscope data. I failed miserable so I will try again the coming weeks. I connected it serially to p5 and created a visual for movement detected and value outputted by both the accelerometer and the gyroscope.

I was able to make a bit of sense of the gyroscope and figured out how to code it so that the duration of the sound is reliant on the user (as long as the user keeps moving, the sound keeps going). However, I was only able to do it along one axis of rotation.

Additionally I got to figure out how to make it so that it produces the drum sound if it is moved faster (this has bugs, though – it has been inconsistent.)

Tone.js Simultaneous Sound Playing Issue

I had to test what sounds worked for tone JS and realized that using 1 envelope caused sounds to get “stuck.” Using 2 envelopes fixed this, but made it so that p5 sound could not play loaded sounds.

Demo of Circuit Playground

I decided to stick with the circuit playground for the Midterm Demo since it is the version that is working best. I decided to loop the sound so that there is a sense of creating music to be enjoyed. The drum sound comes in after the chord sounds loop; ideally to add variety, but I am still figuring that part out (what is feasible for the tech and what makes most sense for the porject).