20 March 2022

Nime Team 22


Schematic
 


For this project i wanted to translate what I built for the unconventional switch into meetings this assignment's parameters. The end result is a musical glove! There are 3 fingers with wires attached to them that play a note, when a user connects a finger to a wire attached to the thumb in a pinching motion the circuit is closed and the finger's associated note plays. The Servo's function is to set the tempo by brushing against metallic ridges and making a loud rhythmic sound. The rate that the servo brushes against the ridges is determined by the potentiometer. Here's a detailed breakdown of each system

The CPE powers the breadboard with 3.3v. The thumb is the only thing pulling power from the breadboard and acts as a switch, the other fingers are also attached to the breadboard and when connected to the thumb close the circuit by grounding themselves in pins A1, A2, and A3

The servo is directly powered by the CPE 5V and has a signal wire attached to A5, the third wire is attached to the CPE’s ground pin 

The potentiometer is powered 3.3v by the CPE and has a signal wire going to pin A4 on the bluefruit. It’s grounded on the breadboard.

How else could the potentiometer be used in this system? Are there better solutions for using the servo?

Project Code:


//Libraries
#include <Adafruit_CircuitPlayground.h>
#include <Servo.h>
// A, B, C, D, E, F, G, A
float notes[] = {440, 493.88, 523.25, 587.33, 659.25, 698.46, 783.99, 880};
float lengths[] = {200, 200, 300, 200, 200, 200, 500};

int pos = 0;
int inc = 1;
Servo myServo; //Declaring Servo

int switchpin = 7;
int potpin = A4; 

void setup() {
  // put your setup code here, to run once:
CircuitPlayground.begin();
Serial.begin(9600);
delay(1000);
//Declaring A1,A2,A3
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT); 
myServo.attach(2);  //A5
}

void loop() {
  // put your main code here, to run repeatedly:
  //Playing tones with the glove, if these pins recieve input (the circuit is closed and this note will play)
if(digitalRead(A1)) CircuitPlayground.playTone(440, 500);
if(digitalRead(A2)) CircuitPlayground.playTone(587.33, 500);
if(digitalRead(A3)) CircuitPlayground.playTone(783.99, 500);

int pot = analogRead(potpin); // read A4 for potentiometer input
if(digitalRead(switchpin)){
  // first state
  int rotation = map(pot, 0, 1023, 0, 180); //sets the servo range bounds
  myServo.write(rotation);
  } else {
    //second state handles Servo bouncing from one one point to another
    if(pos = 0) inc = 1;
    if(pos = 180) inc = -1;
    pos += inc;
    myServo.write(pos);
    int rate = map(pot, 0, 1023, 1, 100);
    Serial.println(pot);
  }
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.