Bill's Music mess
This commit is contained in:
parent
62b7761e9a
commit
8600cbd3e0
@ -1,9 +1,11 @@
|
|||||||
//Center
|
//Center two motors control two frequencies. (jb&bv 25Jan13)
|
||||||
//uses a variable force (pwm duty)
|
//uses a variable force (pwm duty)
|
||||||
//If it feels like a mountain - pushing away from center, then
|
//If it feels like a mountain - pushing away from center, then
|
||||||
//reverse the motor leads
|
//reverse the motor leads or the sign of forceA or forceB
|
||||||
//or for a quick fix in the code: change if(f < 0) to if (f > 0)
|
//or for a quick fix in the code: change if(f < 0) to if (f > 0)
|
||||||
|
|
||||||
|
// notes to me (bv)
|
||||||
|
|
||||||
#include "Motor.h"
|
#include "Motor.h"
|
||||||
#include "Music.h"
|
#include "Music.h"
|
||||||
|
|
||||||
@ -16,8 +18,8 @@ int kB = 2; // spring constant
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
MotorA.init();
|
MotorA.init();
|
||||||
Music.init();
|
Music.init(); // 12-bit sine default (see .cpp file)
|
||||||
Music.setWaveform(0); // only works with 8bit waveforms
|
//Music.setWaveform(0); // only works with 8bit waveforms
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
@ -29,16 +31,11 @@ void loop()
|
|||||||
Music.setFrequency1(posA);
|
Music.setFrequency1(posA);
|
||||||
Music.setFrequency2(posB);
|
Music.setFrequency2(posB);
|
||||||
|
|
||||||
forceA = - kA * (512 - posA);
|
forceA = - kA * (512 - posA); // check wiring???
|
||||||
forceB = kB * (512 - posB);
|
forceB = kB * (512 - posB);
|
||||||
//duty = abs(force);
|
|
||||||
//duty = min(512, duty);
|
|
||||||
|
|
||||||
MotorA.torque(forceA);
|
MotorA.torque(forceA); // forceA [-512 to +511] ???
|
||||||
MotorB.torque(forceB);
|
MotorB.torque(forceB);
|
||||||
|
|
||||||
//if(force < 0) MotorA.direction(FORWARD);
|
|
||||||
//else MotorA.direction(BACKWARD);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -360,7 +360,7 @@ void MMusic::setGain3(uint16_t value)
|
|||||||
|
|
||||||
float MMusic::getGainFloat()
|
float MMusic::getGainFloat()
|
||||||
{
|
{
|
||||||
return float(gain);
|
return float(gain)/65535.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
// SHOULD BE 1, 2 or 3
|
// SHOULD BE 1, 2 or 3
|
||||||
//
|
//
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
#define NUM_OSCILLATORS 2
|
#define NUM_OSCILLATORS 3 //edited BV 29Jan13.
|
||||||
|
|
||||||
|
|
||||||
// current sample rate is 15625 as defined in the init() section
|
// current sample rate is 15625 as defined in the init() section
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user