diff --git a/software/apps/Motion/Center/Center.ino b/software/apps/Motion/Center/Center.ino index e50fc80..78eb5f7 100644 --- a/software/apps/Motion/Center/Center.ino +++ b/software/apps/Motion/Center/Center.ino @@ -7,14 +7,15 @@ #include "Motor.h" #include "Music.h" -int pos; // position from analogRead -int force; // computed from pos and k -int k = 2; // spring constant -int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution +int posA, posB; // position from analogRead +int forceA, forceB; // computed from pos and k +int kA, kB = 2; // spring constant +//int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution void setup() { MotorA.init(); + MotorB.init(); Music.init(); } @@ -22,15 +23,19 @@ void setup() void loop() { - pos = analogRead(A0); + posA = analogRead(A0); + posB = analogRead(A3); - Music.setFrequency(pos); + Music.setFrequency1(posA); + Music.setFrequency2(posB); - force = k * (512 - pos); + forceA = - kA * (512 - posA); + forceB = - kB * (512 - posB); //duty = abs(force); //duty = min(512, duty); - MotorA.torque(force); + MotorA.torque(forceA); //force can be -512 to +511 + MotorB.torque(forceB); //force can be -512 to +511 //if(force < 0) MotorA.direction(FORWARD); //else MotorA.direction(BACKWARD); diff --git a/software/lib/MMM/Music.h b/software/lib/MMM/Music.h index f5798b6..c4515d9 100644 --- a/software/lib/MMM/Music.h +++ b/software/lib/MMM/Music.h @@ -74,26 +74,26 @@ public: void setDetune1(float detune); void setDetune2(float detune); void setDetune3(float detune); - void pitchBend(float b); + void pitchBend(float b); // NOT IMPLEMENTED // WAVEFORM FUNCTIONS - void setWaveform(uint16_t waveForm); - void setWaveform1(uint16_t waveForm); - void setWaveform2(uint16_t waveForm); - void setWaveform3(uint16_t waveForm); + void setWaveform(uint16_t waveForm); // JUST FOR 8bit WAVEFORMS + void setWaveform1(uint16_t waveForm); // + void setWaveform2(uint16_t waveForm); // + void setWaveform3(uint16_t waveForm); // // GAIN FUNCTIONS void setGainFloat(float value); // 0.0 - 1.0 void setGain16bit(uint16_t value); // 0 - 65535 void setGain(uint16_t value); // 0 - 65535 - void setGain(float value); // 0.0 - 1.0 + void setGain(float value); // 0.0 - 1.0 USE THIS void setGain1(uint16_t value); // 0 - 65535 void setGain2(uint16_t value); // 0 - 65535 void setGain3(uint16_t value); // 0 - 65535 - void setGain1(float value); // 0.0 - 1.0 - void setGain2(float value); // 0.0 - 1.0 - void setGain3(float value); // 0.0 - 1.0 - float getGainFloat(); + void setGain1(float value); // 0.0 - 1.0 USE THIS + void setGain2(float value); // 0.0 - 1.0 USE THIS + void setGain3(float value); // 0.0 - 1.0 USE THIS + float getGainFloat(); // 0.0 - 1.0 USE THIS uint16_t getGain(); // NOTE FUNCTIONS @@ -101,7 +101,7 @@ public: void noteOn(uint8_t note); // 0 - 255 void noteOff(uint8_t note); // 0 - 255 void noteOff(); - uint16_t getNoteFrequency(uint8_t note); // 0 - 127 + uint16_t getNoteFrequency(uint8_t note); // 0 - 127 CHECK THIS OUT // ENVELOPE FUNCTIONS void enableEnvelope(); @@ -113,10 +113,10 @@ public: void setSustain16bit(uint16_t sus); // 0 - 65535 void setRelease16bit(uint16_t rel); // 0 - 65535 - void setAttack(uint8_t att); // 0 - 127 - void setDecay(uint8_t dec); // 0 - 127 - void setSustain(uint8_t sus); // 0 - 127 - void setRelease(uint8_t rel); // 0 - 127 + void setAttack(uint8_t att); // 0 - 127 USE THESE ONES + void setDecay(uint8_t dec); // 0 - 127 USE THESE ONES + void setSustain(uint8_t sus); // 0 - 127 USE THESE ONES + void setRelease(uint8_t rel); // 0 - 127 USE THESE ONES void setVelSustain(uint8_t vel); // 0 - 127 void setVelPeak(uint8_t vel); // 0 - 127