Goldsmiths

This commit is contained in:
dviid
2013-03-18 10:51:33 +00:00
parent d938b31e91
commit 05fc0c94af
38 changed files with 152 additions and 1544 deletions
@@ -0,0 +1,30 @@
//FM synthes of a sort
//hang on! (it's unstable and wants to limit cycle)
#include <Music.h>
#define BIT_DEPTH 8 // gives us 16 Waveforms
#include <Motor.h>
byte cnt;
float xf, vf; //
float k = 10.0; // increase FM frequency
float b = 0.40; // increase
float Tf = .030 ; //integration time
void setup(){
Serial.begin(9600);
Music.init();
Music.setWaveform(0);
Music.setGain(1.0f);
MotorA.init();
}
void loop(){
xf += vf * Tf;
vf += (k * (analogRead(A0) - xf) - b*vf) * Tf;
Music.setFrequency(100+vf);
Music.setGain(.001*abs(vf));
MotorA.torque(-500+xf);
//if(cnt++==0)Serial.println(.001*abs(vf));
}