Changes to Motion, Motor and Music Library
Motion library still needs to be fixed. Don't use yet.
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
//reverse the motor leads
|
||||
//or for a quick fix in the code: change if(f < 0) to if (f > 0)
|
||||
|
||||
#include <Motor.h>
|
||||
#include "Motor.h"
|
||||
#include "Music.h"
|
||||
|
||||
int pos; // position from analogRead
|
||||
int force; // computed from pos and k
|
||||
@@ -13,8 +14,8 @@ int duty; // pwm duty for Timer1 (range 0 - 1023) 10-bit resolution
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
MotorA.init();
|
||||
Music.init();
|
||||
|
||||
}
|
||||
|
||||
@@ -23,14 +24,16 @@ void loop()
|
||||
|
||||
pos = analogRead(A0);
|
||||
|
||||
Music.setFrequency(pos);
|
||||
|
||||
force = k * (512 - pos);
|
||||
duty = abs(force);
|
||||
duty = min(512, duty);
|
||||
//duty = abs(force);
|
||||
//duty = min(512, duty);
|
||||
|
||||
MotorA.torque(duty);
|
||||
MotorA.torque(force);
|
||||
|
||||
if(force < 0) MotorA.direction(FORWARD);
|
||||
else MotorA.direction(BACKWARD);
|
||||
//if(force < 0) MotorA.direction(FORWARD);
|
||||
//else MotorA.direction(BACKWARD);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user