Inside of the box, showing servo and breadboard w/ potentiometer. |
For the NIME scaffolding, my first idea was a kind of midi using the speaker of the Circuit Playground Express. My conceptual model used the servo as a kind of metronome with an adjustable speed using the potentiometer. After messing around with the code, I realized that the code for that to happen was interrupting the capacitive touch sensor code so I switched up the purpose of those components. Now, the servo is manually controlled with the potentiometer to create a sound on the inside of the box. The capacitive touch sensors were always a part of the original concept; they would work the best for the midi aesthetic.
The mapping of the inputs to the outputs was simple; three different tones were mapped to the touch sensors and the output was the A0 pin, or the built-in speaker of the CPE. For the potentiometer and the servo, the values of the potentiometer were mapped 1:1 to the 180 degrees of the servo fan.
When it came to the UX, I made sure that the touch sensors were clear and what they did was clear as well; the styrofoam keys I made signify that pressing the pennies (touch sensors) will illicit sound from the speaker of the CPE. On top of that, the sound and the different colored lights that flash when each sensor is touched act as feedback to the user.
How else could I have used the servo and the potentiometer, whether they worked together or separately?
Circuit schematic. |
//CODE BY SAMANTHA BARRIZONTE 2021//DIG3620#include <Adafruit_CircuitPlayground.h>#include <Adafruit_Circuit_Playground.h>#include <Servo.h>#include <math.h>Servo myservo; // create servo object to control a servoint pos = 0; // variable to store the servo positionint potpin = 3; // analog pin used to connect the potentiometerint timer = 0;int val; // variable to store the potentiometer valuesint thresh = 950;int debounce = 15;int r = A6;int x = A7;int s = A4;#define COLOR1 0XFF0000#define COLOR2 0X00FF00#define COLOR3 0X0000FFvoid setup() {Serial.begin(9600);delay(1000);CircuitPlayground.begin();myservo.attach(A2); // attaches the servo on A2 to the servo objectCircuitPlayground.setBrightness(70); //brightness of blinking neopixels}void loop() {val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)myservo.write(val); // sets the servo position according to the scaled valuedelay(10); // waits for the servo to get thereint t = CircuitPlayground.readCap(r); //read pin A6if(t > thresh) {CircuitPlayground.playTone(1760,100);for (int pixel=0; pixel<10; pixel++) { //all neopixels blink along to touch sensorCircuitPlayground.setPixelColor(pixel, COLOR1);}delay(debounce*2);CircuitPlayground.clearPixels();delay(debounce*2);}int y = CircuitPlayground.readCap(x); //read pin A7if(y > thresh) {CircuitPlayground.playTone(440,100);for (int pixel=0; pixel<10; pixel++) { //all neopixels blink along to touch sensorCircuitPlayground.setPixelColor(pixel, COLOR2);}delay(debounce*2);CircuitPlayground.clearPixels();delay(debounce*2);}int i = CircuitPlayground.readCap(s); //read pin A4if(i > thresh) {CircuitPlayground.playTone(880,100);for (int pixel=0; pixel<10; pixel++) { //all neopixels blink along to touch sensorCircuitPlayground.setPixelColor(pixel, COLOR3);}delay(debounce*2);CircuitPlayground.clearPixels();delay(debounce*2);}Serial.println();delay(debounce);}
CONTENT WARNING: FLASHING LIGHTS
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.