Goldsmiths
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
//"Pulse" - small duration positive then negative force
|
||||
// parameters: F1, T1, D1, F2, T2, D2
|
||||
|
||||
#define BIT_DEPTH 12
|
||||
|
||||
#include <Motor.h>
|
||||
#include <Music.h>
|
||||
|
||||
void setup(){
|
||||
MotorB.init();
|
||||
Music.init();
|
||||
|
||||
Music.setWaveform(SINE);
|
||||
Music.enableEnvelope();
|
||||
Music.setAttack(10);
|
||||
Music.setDecay(10);
|
||||
Music.setRelease(10);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
//for (int i; i < 512; i + 100){
|
||||
MotorB.torque(40);
|
||||
Music.noteOn(map(analogRead(A3),0,1023,30,60));
|
||||
delay (20);
|
||||
Music.noteOff();MotorB.torque(0);
|
||||
delay (150);
|
||||
MotorB.torque(-70);
|
||||
Music.noteOn(map(analogRead(A3),0,1023,35,65));
|
||||
delay (40);
|
||||
Music.noteOff();MotorB.torque(0);
|
||||
MotorB.torque(0);
|
||||
delay (750);
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <Motor.h>
|
||||
|
||||
void setup() {
|
||||
MotorA.init();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MotorA.torque(500);
|
||||
delay(2000);
|
||||
MotorA.torque(-500);
|
||||
delay(2000);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
|
||||
#include <Motion.h>
|
||||
#include <Motor.h>
|
||||
|
||||
#define NEW '!'
|
||||
#define OK '*'
|
||||
#define PRINT '&'
|
||||
|
||||
int table[800];
|
||||
int len = 800;
|
||||
|
||||
char buf[32] = "";
|
||||
int cnt = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
MotorA.init();
|
||||
MotionA.init(INPUTA0);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MotionA.update_position();
|
||||
int i = (int) (((float) MotionA.Xin / 1023.0) * len);
|
||||
int f = table[i];
|
||||
MotorA.torque(f);
|
||||
|
||||
// TODO - send position back to interface
|
||||
/*
|
||||
cnt++;
|
||||
if(cnt == 1000) {
|
||||
sprintf(buf, "%d %d %d", MotionA.Xin, i, f);
|
||||
Serial.println(buf);
|
||||
cnt = 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void serialEvent() {
|
||||
|
||||
if(Serial.available()) {
|
||||
char in = (char)Serial.read();
|
||||
if(in == NEW) {
|
||||
Serial.print(OK);
|
||||
len = serial_read();
|
||||
for(int i = 0; i < len; i++) {
|
||||
table[i] = serial_read();
|
||||
}
|
||||
} else if(in == PRINT) {
|
||||
Serial.println(len);
|
||||
for(int i = 0; i < len; i++) {
|
||||
Serial.print(table[i]);
|
||||
Serial.print(';');
|
||||
}
|
||||
Serial.print('#');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int serial_read() {
|
||||
while(Serial.available() < 2);
|
||||
int l = Serial.read();
|
||||
int h = Serial.read();
|
||||
Serial.write(OK);
|
||||
return (h * 256) + l;
|
||||
}
|
||||
Reference in New Issue
Block a user