diff --git a/software/apps/M&MStudioBV/--ProcessingProfile/CirclesClick/CirclesClick.pde b/software/apps/M&MStudioBV/--ProcessingProfile/CirclesClick/CirclesClick.pde new file mode 100644 index 0000000..a844331 --- /dev/null +++ b/software/apps/M&MStudioBV/--ProcessingProfile/CirclesClick/CirclesClick.pde @@ -0,0 +1,22 @@ + +// Click within the image to change +// the value of the rectangle + +int value = 20; + +void setup(){ + size(300,400); + stroke(value); + background(250); +} + +void draw(){ + value = mouseX; + fill(value); + stroke(value-100); +} + +void mouseReleased() { + ellipse(mouseX,mouseY,20,20); +} + diff --git a/software/apps/M&MStudioBV/--ProcessingProfile/DragBeads/DragBeads.pde b/software/apps/M&MStudioBV/--ProcessingProfile/DragBeads/DragBeads.pde new file mode 100644 index 0000000..e446bf8 --- /dev/null +++ b/software/apps/M&MStudioBV/--ProcessingProfile/DragBeads/DragBeads.pde @@ -0,0 +1,34 @@ + +int[] altitude = { 10, 20, 30, 40, 50, 40, 30, 20, 10, 0 }; +int i; +int s = 80; + +void setup() { + size(800,100); +} +void draw(){ + background(200); + stroke(150); + line(0,50,799,50); + stroke(0); + + for (i = 0; i < 9; i = i+1) { + line(s*i,altitude[i],s*(i+1),altitude[i+1]); + } + + line(s*9, altitude[9], s*10-1, 50); + + for (i = 0; i < 9; i = i+1) { + ellipse(s*(i+1),altitude[i+1], 10, 10); + } + + if (mousePressed == true) { + int pos = (mouseX+40)/s; + altitude[pos]=mouseY; + } +} + +void mouseReleased() { + int pos = mouseX/s; + altitude[pos]=mouseY; +} diff --git a/software/apps/M&MStudioBV/--ProcessingProfile/Dragging/Dragging.pde b/software/apps/M&MStudioBV/--ProcessingProfile/Dragging/Dragging.pde new file mode 100644 index 0000000..99fcc54 --- /dev/null +++ b/software/apps/M&MStudioBV/--ProcessingProfile/Dragging/Dragging.pde @@ -0,0 +1,59 @@ +// two-dimensional array? +// i = 1, 8; +// int F[], // shown an height +// x[i], // + +// constrain x[i] sq(F[i]+100-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]+100-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest]+100,20,20); + +text (Integer.toString(ibest), mouseX+10, mouseY-12); +text (Integer.toString(F[ibest]), mouseX+10, mouseY); +text (Integer.toString(x[ibest]), mouseX+10, mouseY+12); + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + x[ibest] = min(x[ibest+1],max(x[ibest-1],mouseX)); + F[ibest] = mouseY-100; + + } +} + + + diff --git a/software/apps/M&MStudioBV/--ProcessingProfile/DraggingFixedWidths/DraggingFixedWidths.pde b/software/apps/M&MStudioBV/--ProcessingProfile/DraggingFixedWidths/DraggingFixedWidths.pde new file mode 100644 index 0000000..79fe817 --- /dev/null +++ b/software/apps/M&MStudioBV/--ProcessingProfile/DraggingFixedWidths/DraggingFixedWidths.pde @@ -0,0 +1,83 @@ +// two-dimensional array? +// i = 1, 8; +// int F[], // shown an height +// x[i], // + +// constrain x[i] sq(F[i]+100-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]+100-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest]+100,20,20); + +text (Integer.toString(ibest), mouseX+10, mouseY-12); +text (Integer.toString(F[ibest]), mouseX+10, mouseY); +text (Integer.toString(x[ibest]), mouseX+10, mouseY+12); + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + x[ibest] = min(x[ibest+1],max(x[ibest-1],mouseX)); + F[ibest] = mouseY-100; + + } + +//plot "terrain" assuming 80 point separation of F[]'s + pushMatrix(); + translate(0,height/2); + /*for (i = 0; i sq(F[i]+100-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]+100-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest]+100,20,20); + +text (Integer.toString(ibest), mouseX+10, mouseY-12); +text (Integer.toString(F[ibest]), mouseX+10, mouseY); +text (Integer.toString(x[ibest]), mouseX+10, mouseY+12); + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + x[ibest] = min(x[ibest+1],max(x[ibest-1],mouseX)); + F[ibest] = mouseY-100; + + } + +//plot "terrain" assuming 80 point separation of F[]'s + pushMatrix(); + translate(0,height/2); + /*for (i = 0; i sq(F[i]+100-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]+100-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest]+100,20,20); + +text (Integer.toString(ibest), mouseX+10, mouseY-12); +text (Integer.toString(F[ibest]), mouseX+10, mouseY); +text (Integer.toString(x[ibest]), mouseX+10, mouseY+12); + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + x[ibest] = min(x[ibest+1],max(x[ibest-1],mouseX)); + F[ibest] = mouseY - 100; + if (mouseY < 0) F[ibest] = -100; + if (mouseY > 200) F[ibest] = 100; + } + +//plot "terrain" assuming 80 point separation of F[]'s + pushMatrix(); + translate(0,height/2); + + top = 0; + FF = F[0]; + for (i = 0; i < n; i = i+1) { + s = x[i+1]-x[i]+1; // increment used for plotting + inc = 0.01*(F[i+1]-F[i])/s; + for (j = 0; j < s; j = j+1) { + FF = FF + inc; + top = top + FF; // j increments of inc = F diff. + line(x[i]+j,height,x[i]+j,top); + } + } + popMatrix(); +} + + + diff --git a/software/apps/M&MStudioBV/--ProcessingProfile/DraggingWidthsWorks/DraggingWidthsWorks.pde b/software/apps/M&MStudioBV/--ProcessingProfile/DraggingWidthsWorks/DraggingWidthsWorks.pde new file mode 100644 index 0000000..9d5efcb --- /dev/null +++ b/software/apps/M&MStudioBV/--ProcessingProfile/DraggingWidthsWorks/DraggingWidthsWorks.pde @@ -0,0 +1,91 @@ +// two-dimensional array? +// i = 1, 8; +// int F[], // shown an height +// x[i], // + +// constrain x[i] sq(F[i]+100-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]+100-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest]+100,20,20); + +text (Integer.toString(ibest), mouseX+10, mouseY-12); +text (Integer.toString(F[ibest]), mouseX+10, mouseY); +text (Integer.toString(x[ibest]), mouseX+10, mouseY+12); + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + x[ibest] = min(x[ibest+1],max(x[ibest-1],mouseX)); + F[ibest] = mouseY - 100; + if (mouseY < 0) F[ibest] = -100; + if (mouseY > 200) F[ibest] = 100; + } + +//plot "terrain" assuming 80 point separation of F[]'s + pushMatrix(); + translate(0,height/2); + + top = 0; + FF = F[0]; + for (i = 0; i < n; i = i+1) { + s = x[i+1]-x[i]+1; // increment used for plotting + inc = 0.01*(F[i+1]-F[i])/s; + for (j = 0; j < s; j = j+1) { + FF = FF + inc; + top = top + FF; // j increments of inc = F diff. + line(x[i]+j,height,x[i]+j,top); + } + } + popMatrix(); +} + +void keyPressed() { + if (key == CODED) { + if (keyCode == UP) --F[ibest]; + if (keyCode == DOWN) ++F[ibest]; + if (keyCode == RIGHT) ++x[ibest]; + if (keyCode == LEFT) --x[ibest]; + } +} + + diff --git a/software/apps/M&MStudioBV/--ProcessingProfile/InterpolationReady/InterpolationReady.pde b/software/apps/M&MStudioBV/--ProcessingProfile/InterpolationReady/InterpolationReady.pde new file mode 100644 index 0000000..e89d1e1 --- /dev/null +++ b/software/apps/M&MStudioBV/--ProcessingProfile/InterpolationReady/InterpolationReady.pde @@ -0,0 +1,50 @@ +// Profile of forces and terrain + +int n = 10; //number of values of F calculated for each s +int s = 80; //number of samples for each n +int[] F = new int[11]; //course Force values +float[] FF = new float[800]; //fine Forces interpolated +int i,j; +//int s = 80; +//int n = 10; +int pos; + +void setup() { + size(800,200); // double height to see what interpolation looks like +} + + +void draw() { + background(200); + stroke(150); + line(0,50,n*s-1,50); + stroke(0); + + for (i = 0; i sq(F[i]+100-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]+100-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest]+100,20,20); + +text (Integer.toString(ibest), mouseX+10, mouseY-12); +text (Integer.toString(F[ibest]), mouseX+10, mouseY); +text (Integer.toString(x[ibest]), mouseX+10, mouseY+12); + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + x[ibest] = min(x[ibest+1],max(x[ibest-1],mouseX)); + F[ibest] = mouseY - 100; + if (mouseY < 0) F[ibest] = -100; + if (mouseY > 200) F[ibest] = 100; + } + +//plot "terrain" assuming 80 point separation of F[]'s + pushMatrix(); + translate(0,height/2); + + top = 0; + FF = F[0]; + for (i = 0; i < n; i = i+1) { + s = x[i+1]-x[i]+1; // increment used for plotting + inc = 0.01*(F[i+1]-F[i])/s; + for (j = 0; j < s; j = j+1) { + FF = FF + inc; + top = top + FF; // j increments of inc = F diff. + line(x[i]+j,height,x[i]+j,top); + } + } + popMatrix(); +} + +void keyPressed() { + if (key == CODED) { + if (keyCode == UP) --F[ibest]; + if (keyCode == DOWN) ++F[ibest]; + if (keyCode == RIGHT) ++x[ibest]; + if (keyCode == LEFT) --x[ibest]; + } +} + + diff --git a/software/apps/M&MStudioBV/--ProcessingProfile/ProfileFixedWidths/ProfileFixedWidths.pde b/software/apps/M&MStudioBV/--ProcessingProfile/ProfileFixedWidths/ProfileFixedWidths.pde new file mode 100644 index 0000000..16fca5b --- /dev/null +++ b/software/apps/M&MStudioBV/--ProcessingProfile/ProfileFixedWidths/ProfileFixedWidths.pde @@ -0,0 +1,82 @@ +// Profile of forces and terrain + +int n = 10; //number of values of F calculated for each s +int s = 80; //number of samples for each n +int[] F = new int[11]; // Force values [-512 to +511] scaled for plot? +float FF; // forces interpolated +float top; // terrain value (integral of forces) +float inc; // interpolated slope ( F[i+1] - F[i] ) / s +int i,j; +int pos; +int vt = 50; //vertical translation for force curve + + + +void setup() { + size(800,800); // double height to see what interpolation looks like + for(i=0;i sq(F[i]-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest],20,20); + // } + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + F[ibest] = mouseY; + x[ibest] = min(x[ibest+1],mouseX); + x[ibest] = max(x[ibest-1],mouseX); + } + +} + + + diff --git a/software/apps/M&MStudioBV/ABSlaveMusic/ABSlaveMusic.ino b/software/apps/M&MStudioBV/ABSlaveMusic/ABSlaveMusic.ino new file mode 100644 index 0000000..63d0af8 --- /dev/null +++ b/software/apps/M&MStudioBV/ABSlaveMusic/ABSlaveMusic.ino @@ -0,0 +1,25 @@ +// CenterAB - both motors +// CenterA at xB, CenterB at xA? +// feels like "Slave" + +#include +#include + +int duty, count, fout; +int xA, xB, foutA, foutB; + +void setup(){ + MotorA.init(); + MotorB.init(); +} + +void loop(){ + xA = analogRead(A0); + xB = analogRead(A3); + foutA = 6*(xB-xA); // this will peak at x=1024/6 + MotorA.torque(foutA); // 1/4 or 1/2 ? + + foutB = 6*(xA-xB); // this will peak at x=1024/6 + MotorB.torque(foutB); // 1/4 or 1/2 ? + +} diff --git a/software/apps/M&MStudioBV/ABSlaveMusicWarble/ABSlaveMusicWarble.ino b/software/apps/M&MStudioBV/ABSlaveMusicWarble/ABSlaveMusicWarble.ino new file mode 100644 index 0000000..e21c843 --- /dev/null +++ b/software/apps/M&MStudioBV/ABSlaveMusicWarble/ABSlaveMusicWarble.ino @@ -0,0 +1,56 @@ +// CenterAB - both motors +// Freqequency1 B->Frequency2 +//CenterA at xB, CenterB at xA? +//feels like "Slave" +//position on A0, pwm:D9, dir:D8,D7 +//CenterB +//position on A3, pwm:D10, dir:D11,D12 + + +#include +#include +#define BIT_DEPTH 8 +#define NUM_OSCILLATORS 2 + +int duty, count, fout; +int xA, xB, foutA, foutB; + +void setup(){ + Serial.begin(9600); + MotorA.init(); + MotorB.init(); + Music.init(); + Music.setWaveform1(0);//8bit + Music.setWaveform2(0); + Music.setGain1(1.0f); + Music.setGain2(1.0f); +} + +void loop(){ + + xA = analogRead(A0); + Music.setFrequency1(map (xA, 0, 1023, 40, 2000)); + + xB = analogRead(A3); + Music.setFrequency2(map (xB, 0, 1023, 40, 2000)); + + foutA = -6*(xA-xB); // this will peak at x=1024/6 + MotorA.torque(foutA); // 1/4 or 1/2 ? + + foutB = -6*(xB-xA); // this will peak at x=1024/6 + MotorB.torque(foutB); // 1/4 or 1/2 ? + + Music.setGain(float(abs(xA-xB))/1024.0f); + // print every 1000 cycles + if(count++>=0){ + count=-500; + Serial.print(xA,DEC); + Serial.print(" "); + Serial.print(foutA,DEC); + Serial.print(" "); + Serial.print(xB,DEC); + Serial.print(" "); + Serial.println(foutB,DEC); + } + +} diff --git a/software/apps/M&MStudioBV/ABslave/ABslave.ino b/software/apps/M&MStudioBV/ABslave/ABslave.ino new file mode 100644 index 0000000..ea396cb --- /dev/null +++ b/software/apps/M&MStudioBV/ABslave/ABslave.ino @@ -0,0 +1,43 @@ +// CenterAB - both motors + +//CenterA at xB, CenterB at xA? +//feels like "Double Toggle" +//position on A0, pwm:D9, dir:D8,D7 +//CenterB +//position on A3, pwm:D10, dir:D11,D12 + + +#include + +int duty, count, fout; +int xA, xB, foutA, foutB; + +void setup(){ + Serial.begin(9600); + MotorA.init(); + MotorB.init(); +} + +void loop(){ + + xA = analogRead(A0); + xB = analogRead(A3); + foutA = 6*(xA-xB); // this will peak at x=1024/6 + MotorA.torque(foutA); // 1/4 or 1/2 ? + + foutB = 6*(xB-xA); // this will peak at x=1024/6 + MotorB.torque(foutB); // 1/4 or 1/2 ? + + // print every 1000 cycles + if(count++>=0){ + count=-500; + Serial.print(xA,DEC); + Serial.print(" "); + Serial.print(foutA,DEC); + Serial.print(" "); + Serial.print(xB,DEC); + Serial.print(" "); + Serial.println(foutB,DEC); + } + +} diff --git a/software/apps/M&MStudioBV/Bumps4/Bumps4.ino b/software/apps/M&MStudioBV/Bumps4/Bumps4.ino new file mode 100644 index 0000000..447850b --- /dev/null +++ b/software/apps/M&MStudioBV/Bumps4/Bumps4.ino @@ -0,0 +1,74 @@ +//plucks - four bumps +//three notes (400,500,600hz) +//can't get Music.setGain1, etc to work only Music.setGain() starts all of them. + +#include +#include + +int x, xold, xt, F; // input position x, output force F +int K = 10; // slope constant +byte count; //for print count-down + +void setup(){ + Music.init(); + Music.setFrequency1(200); + Music.setFrequency2(250); + Music.setFrequency3(300); + + + MotorA.init(); + + Serial.begin(9600); + x = analogRead(A0); // initialize x +} + +void loop(){ + xold = x; + x = analogRead(A0); + +// did xold - x include 125, 375, 625, 875? or x%250 = 125 + +if (((xold <= 125) && (x > 125)) || ((xold >= 125) && (x < 125))){ + Music.setGain1(1.0f); + //Music.setFrequency(200); +} +if (((xold <= 375) && (x > 375)) || ((xold >= 375) && (x < 375))){ + Music.setGain2(1.0f); + //Music.setFrequency(250); +} +if (((xold <= 625) && (x > 625)) || ((xold >= 625) && (x < 625))){ + Music.setGain3(1.0f); + //Music.setFrequency(300); +} +if (((xold <= 875) && (x > 875)) || ((xold >= 875) && (x < 875))){ + Music.setGain1(1.0f); + //Music.setFrequency(400); + } + else{ + Music.setGain1(0.995f*Music.getGain1Float()); + Music.setGain2(0.995f*Music.getGain2Float()); + Music.setGain3(0.995f*Music.getGain3Float()); + } + + + + xt = x % 250; //same force for each 250 ranage + F = 0; + if (xt > 60) F = - K * (xt - 60); + if (xt > 80) F = - K * (100 - xt); + if (xt > 120) F = K * (140 - xt); + if (xt > 140) F = 0; + MotorA.torque(F); + + + // print every 256 cycles + if(count++==0){ + Serial.print(x); + Serial.print(" "); + Serial.print(xt); + Serial.print(" "); + Serial.println(F); + } + +} + diff --git a/software/apps/M&MStudioBV/CenterABM/CenterABM.ino b/software/apps/M&MStudioBV/CenterABM/CenterABM.ino new file mode 100644 index 0000000..08112bc --- /dev/null +++ b/software/apps/M&MStudioBV/CenterABM/CenterABM.ino @@ -0,0 +1,42 @@ +// CenterAB - both motors + +//CenterA +//position on A0, pwm:D9, dir:D8,D7 +//CenterB +//position on A3, pwm:D10, dir:D11,D12 + + +#include + +int duty, count, fout; +int xA, xB, foutA, foutB; + +void setup(){ + Serial.begin(9600); + MotorA.init(); + MotorB.init(); +} + +void loop(){ + + xA = analogRead(A0); + foutA = 2*(512 - xA); // this will peak at x=1024/2 + MotorA.torque(foutA); // 1/4 or 1/2 ? + + xB = analogRead(A3); + foutB = (512 - xB); // this will peak at x=1024/6 + MotorB.torque(foutB); // 1/4 or 1/2 ? + + // print every 1000 cycles + if(count++>=0){ + count=-1000; + Serial.print(xA,DEC); + Serial.print(" "); + Serial.print(foutA,DEC); + Serial.print(" "); + Serial.print(xB,DEC); + Serial.print(" "); + Serial.println(foutB,DEC); + } + +} diff --git a/software/apps/M&MStudioBV/CenterABtoggle/CenterABtoggle.ino b/software/apps/M&MStudioBV/CenterABtoggle/CenterABtoggle.ino new file mode 100644 index 0000000..463e7f3 --- /dev/null +++ b/software/apps/M&MStudioBV/CenterABtoggle/CenterABtoggle.ino @@ -0,0 +1,43 @@ +// CenterAB - both motors + +//CenterA at xB, CenterB at xA? +//feels like "Double Toggle" +//position on A0, pwm:D9, dir:D8,D7 +//CenterB +//position on A3, pwm:D10, dir:D11,D12 + + +#include + +int duty, count, fout; +int xA, xB, foutA, foutB; + +void setup(){ + Serial.begin(9600); + MotorA.init(); + MotorB.init(); +} + +void loop(){ + + xA = analogRead(A0); + xB = analogRead(A3); + foutA = 6*(xB-512); // this will peak at x=1024/6 + MotorA.torque(foutA); // 1/4 or 1/2 ? + + foutB = 6*(xA-512); // this will peak at x=1024/6 + MotorB.torque(foutB); // 1/4 or 1/2 ? + + // print every 1000 cycles + if(count++>=0){ + count=-500; + Serial.print(xA,DEC); + Serial.print(" "); + Serial.print(foutA,DEC); + Serial.print(" "); + Serial.print(xB,DEC); + Serial.print(" "); + Serial.println(foutB,DEC); + } + +} diff --git a/software/apps/M&MStudioBV/FM/CenterFSR_A/CenterFSR_A.ino b/software/apps/M&MStudioBV/FM/CenterFSR_A/CenterFSR_A.ino new file mode 100644 index 0000000..d394241 --- /dev/null +++ b/software/apps/M&MStudioBV/FM/CenterFSR_A/CenterFSR_A.ino @@ -0,0 +1,34 @@ +//CenterFSR-A +//position on A0, pwm:D9, dir:D8,D7 +//FSR on A1 and D4 + +// BUZZ! (float vs int?) +#include "Motor.h" + +int x, duty, fin; +float fout; +byte count; // used as counter + +void setup(){ + Serial.begin(9600); + MotorA.init(); + //for FSR + pinMode(A1,INPUT); + digitalWrite(A1,HIGH); + pinMode(4,OUTPUT); + digitalWrite(4,LOW); +} + +void loop(){ + fin = 1024 - analogRead(A1); + x = analogRead(A0)-512; + fout = - .004*(float(fin)*float(x)); + MotorA.torque(fout); + if(count++ == 0){ + Serial.print(x,DEC); + Serial.print(" "); + Serial.print(fin,DEC); + Serial.print(" "); + Serial.println(fout,DEC); + } +} diff --git a/software/apps/M&MStudioBV/FM/FM.ino b/software/apps/M&MStudioBV/FM/FM.ino new file mode 100644 index 0000000..b7eb8c0 --- /dev/null +++ b/software/apps/M&MStudioBV/FM/FM.ino @@ -0,0 +1,31 @@ +//FM synthes of a sort +//hang on! it's unstable and wants to limit cycle + + +#include +#define BIT_DEPTH 8 // gives us 16 Waveforms + +#include + +byte cnt; +float xf, vf; // +float k = 6.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)); +} diff --git a/software/apps/M&MStudioBV/FM/FMGraph/FMGraph.pde b/software/apps/M&MStudioBV/FM/FMGraph/FMGraph.pde new file mode 100644 index 0000000..326cc39 --- /dev/null +++ b/software/apps/M&MStudioBV/FM/FMGraph/FMGraph.pde @@ -0,0 +1,63 @@ +// Graphing sketch + + + // This program takes ASCII-encoded strings + // from the serial port at 9600 baud and graphs them. It expects values in the + // range 0 to 1023, followed by a newline, or newline and carriage return + + // Created 20 Apr 2005 + // Updated 18 Jan 2008 + // by Tom Igoe + // This example code is in the public domain. + + import processing.serial.*; + + Serial myPort; // The serial port + int xPos = 1; // horizontal position of the graph + + void setup () { + // set the window size: + size(400, 300); + + // List all the available serial ports + println(Serial.list()); + // I know that the first port in the serial list on my mac + // is always my Arduino, so I open Serial.list()[0]. + // Open whatever port is the one you're using. + myPort = new Serial(this, Serial.list()[0], 9600); + // don't generate a serialEvent() unless you get a newline character: + myPort.bufferUntil('\n'); + // set inital background: + background(0); + } + void draw () { + // everything happens in the serialEvent() + } + + void serialEvent (Serial myPort) { + // get the ASCII string: + String inString = myPort.readStringUntil('\n'); + + if (inString != null) { + // trim off any whitespace: + inString = trim(inString); + // convert to an int and map to the screen height: + float inByte = float(inString); + inByte = map(inByte, 0, 1023, 0, height); + + // draw the line: + stroke(127,34,255); + line(xPos, height, xPos, height - inByte); + + // at the edge of the screen, go back to the beginning: + if (xPos >= width) { + xPos = 0; + background(0); + } + else { + // increment the horizontal position: + xPos++; + } + } + } + diff --git a/software/apps/M&MStudioBV/FSR/Bumps4FSR/Bumps4FSR.ino b/software/apps/M&MStudioBV/FSR/Bumps4FSR/Bumps4FSR.ino new file mode 100644 index 0000000..7d3b9d3 --- /dev/null +++ b/software/apps/M&MStudioBV/FSR/Bumps4FSR/Bumps4FSR.ino @@ -0,0 +1,97 @@ +//plucks - four bumps +//three notes (400,500,600hz) +//can't get Music.setGain1, etc to work only Music.setGain() starts all of them. +//requires FSR attached to A + +#define NUM_OSCILLATORS 3 +#define BIT_DEPTH 8 + +#include +#include + +int x, xold, xt; // input position x, output force F +float K = 20; // slope constant +byte count; //for print count-down +float fin; // scaled to be 0.0 - 1.0 +float fout; // from FSR + +void setup(){ + Music.init(); + Music.setFrequency1(200); + Music.setFrequency2(250); + Music.setFrequency3(300); + + //FSR-A + pinMode(A1,INPUT); + digitalWrite(A1,HIGH); //set pull-up + pinMode(4,OUTPUT); + digitalWrite(4,LOW); + //FSR-B + pinMode(A4,INPUT); + digitalWrite(A4,HIGH); //set pull-up + pinMode(5,OUTPUT); + digitalWrite(5,LOW); + + Serial.begin(9600); + + MotorA.init(); + + Serial.begin(9600); + x = analogRead(A0); // initialize x +} + +void loop(){ + xold = x; + x = analogRead(A0); + +// did xold - x include 125, 375, 625, 875? or x%250 = 125 + +if (((xold <= 125) && (x > 125)) || ((xold >= 125) && (x < 125))){ + Music.setGain1(fin*fin); + Music.setFrequency1(200); +} +if (((xold <= 375) && (x > 375)) || ((xold >= 375) && (x < 375))){ + Music.setGain2(fin*fin); + //Music.setFrequency(250); +} +if (((xold <= 625) && (x > 625)) || ((xold >= 625) && (x < 625))){ + Music.setGain3(fin*fin); + //Music.setFrequency(300); +} +if (((xold <= 875) && (x > 875)) || ((xold >= 875) && (x < 875))){ + Music.setGain1(fin*fin); + Music.setFrequency1(400); + } + else{ + Music.setGain1(0.995f*Music.getGain1()); + Music.setGain2(0.995f*Music.getGain2()); + Music.setGain3(0.995f*Music.getGain3()); + } + fin = 1000 - analogRead(A1); // invert and shift + fin = max (0, fin); // make sure it's > 0 + fin = min (1023, fin); // and < 1023 + fin = fin/1000; // scale 0-1.0 + fin = fin*fin; //square it for more effect near 1.0. + xt = x % 250; //same force for each 250 ranage + fout = 0; + if (xt > 60) fout = - K * (xt - 60); + if (xt > 80) fout = - K * (100 - xt); + if (xt > 120) fout = K * (140 - xt); + if (xt > 140) fout = 0; + fout = fout * fin; + MotorA.torque(fout); + + + // print every 256 cycles + if(count++==0){ + Serial.print(x); + Serial.print(" "); + Serial.print(xt); + Serial.print(" "); + Serial.print(fin); + Serial.print(" "); + Serial.println(fout); + } + +} + diff --git a/software/apps/M&MStudioBV/FSR/FSR_AB_center/FSR_AB_center.ino b/software/apps/M&MStudioBV/FSR/FSR_AB_center/FSR_AB_center.ino new file mode 100644 index 0000000..ad1e1b1 --- /dev/null +++ b/software/apps/M&MStudioBV/FSR/FSR_AB_center/FSR_AB_center.ino @@ -0,0 +1,37 @@ +// FSR A and B +// stick-slip + +#include +int xA, finA, foutA; //fout gets too big if fout=fin*x; +float x, fin, fout; +byte c; + +void setup(){ + //FSR-A + pinMode(A1,INPUT); + digitalWrite(A1,HIGH); //set pull-up + pinMode(4,OUTPUT); + digitalWrite(4,LOW); + //FSR-B + pinMode(A4,INPUT); + digitalWrite(A4,HIGH); //set pull-up + pinMode(5,OUTPUT); + digitalWrite(5,LOW); + + //Motors + MotorA.init(); + MotorB.init(); + + Serial.begin(9600); +} +void loop(){ + x = 512 - analogRead(A0); //in:[0,1023] out: [-512,511] + fin = 1024 - analogRead(A1); //in:[1023,0] out [0,1023] + fout = x*fin/500; + MotorA.torque(fout); + + x = 512 - analogRead(A3); //in:[0,1023] out: [-512,511] + fin = 1024 - analogRead(A4); //in:[1023,0] out [0,1023] + fout = x*fin/500; + MotorB.torque(fout); +} diff --git a/software/apps/M&MStudioBV/FSR/FSR_AB_test/FSR_AB_test.ino b/software/apps/M&MStudioBV/FSR/FSR_AB_test/FSR_AB_test.ino new file mode 100644 index 0000000..ededaf5 --- /dev/null +++ b/software/apps/M&MStudioBV/FSR/FSR_AB_test/FSR_AB_test.ino @@ -0,0 +1,20 @@ +// FSR A and B test +void setup(){ + //FSR-A + pinMode(A1,INPUT); + digitalWrite(A1,HIGH); //set pull-up + pinMode(4,OUTPUT); + digitalWrite(4,LOW); + //FSR-B + pinMode(A4,INPUT); + digitalWrite(A4,HIGH); //set pull-up + pinMode(5,OUTPUT); + digitalWrite(5,LOW); + + Serial.begin(9600); +} +void loop(){ + Serial.print(analogRead(A1)); + Serial.print(" "); + Serial.println(analogRead(A4)); +} diff --git a/software/apps/M&MStudioBV/FSR/FSR_D4_OUTPUT/FSR_D4_OUTPUT.ino b/software/apps/M&MStudioBV/FSR/FSR_D4_OUTPUT/FSR_D4_OUTPUT.ino new file mode 100644 index 0000000..52ba259 --- /dev/null +++ b/software/apps/M&MStudioBV/FSR/FSR_D4_OUTPUT/FSR_D4_OUTPUT.ino @@ -0,0 +1,17 @@ +void setup(){ + pinMode(A1,INPUT); + pinMode(4,OUTPUT); + digitalWrite(4,LOW); //sets ground + digitalWrite(A1,HIGH); //sets pull-up +} +void loop(){ + digitalWrite(A1,LOW); + digitalWrite(4,HIGH); + delay(1000); + digitalWrite(A1,HIGH); + digitalWrite(4,LOW); + delay(1000); +} + +//does D4 actually go 5v to GND? +//yes, if D4 is OUTPUT. diff --git a/software/apps/M&MStudioBV/FSR/HumpFSR_A/HumpFSR_A.ino b/software/apps/M&MStudioBV/FSR/HumpFSR_A/HumpFSR_A.ino new file mode 100644 index 0000000..9e71054 --- /dev/null +++ b/software/apps/M&MStudioBV/FSR/HumpFSR_A/HumpFSR_A.ino @@ -0,0 +1,36 @@ +//HumpFSR-A +//same as CenterFSR-A with sign reversal +//position on A0, pwm:D9, dir:D8,D7 +//FSR on A1 and D4 + +// BUZZ! (float vs int?) +#include "Motor.h" + +int x, duty, fin; +float fout; +byte count; // used as counter + +void setup(){ + Serial.begin(9600); + MotorA.init(); + //for FSR + pinMode(A1,INPUT); + digitalWrite(A1,HIGH); + pinMode(4,OUTPUT); + digitalWrite(4,LOW); +} + +void loop(){ + fin = 1024 - analogRead(A1); + x = analogRead(A0)-512; + fout = .004*(float(fin)*float(x)); + duty = min(1023,fout); + MotorA.torque(fout); + if(count++ == 0){ + Serial.print(x,DEC); + Serial.print(" "); + Serial.print(fin,DEC); + Serial.print(" "); + Serial.println(fout,DEC); + } +} diff --git a/software/apps/M&MStudioBV/FSR/SandFSR_A/SandFSR_A.ino b/software/apps/M&MStudioBV/FSR/SandFSR_A/SandFSR_A.ino new file mode 100644 index 0000000..15ade1c --- /dev/null +++ b/software/apps/M&MStudioBV/FSR/SandFSR_A/SandFSR_A.ino @@ -0,0 +1,33 @@ +#include "Motor.h" + +int x; //position +float fin; //from hall-sensor [ wired GND to A1 ] +float fout; //force +int duty; // max 1024 +byte c; // counter to send data every 256 cycles + +void setup(){ + MotorA.init(); + pinMode(A1,INPUT); //used for FSR [A1 to D4] + pinMode(4,OUTPUT); //used for FSR as GND + digitalWrite(A1,HIGH); //enable pull-up resistor + digitalWrite(4,LOW); //GND for FSR + //TimerOne + Serial.begin(9600); +} + +void loop(){ + fin = analogRead(A1) - 1000; + //fout = random(fin); + fout = 2*fin + random(fin); // range [0,4096]; + fout = fout/3; + MotorA.torque(fout); + // Timer1.pwm(9,duty); //output force + + if(c++==0){ + Serial.print(fin); + Serial.print(" "); + Serial.println(fout); + } +} + diff --git a/software/apps/M&MStudioBV/Gran/GongRoarCockShort.wav b/software/apps/M&MStudioBV/Gran/GongRoarCockShort.wav new file mode 100644 index 0000000..a8b4954 Binary files /dev/null and b/software/apps/M&MStudioBV/Gran/GongRoarCockShort.wav differ diff --git a/software/apps/M&MStudioBV/Gran/GranFlash.rtf b/software/apps/M&MStudioBV/Gran/GranFlash.rtf new file mode 100644 index 0000000..7bdb2c1 --- /dev/null +++ b/software/apps/M&MStudioBV/Gran/GranFlash.rtf @@ -0,0 +1,13 @@ +{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf510 +{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\colortbl;\red255\green255\blue255;} +\margl1440\margr1440\vieww10800\viewh8400\viewkind0 +\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural + +\f0\fs24 \cf0 32K flash program memory 8-bit bytes\ +8K/sec = 4 seconds\ +\ +use 20K ?\ +\ +granular synthesis is like wave-table synthesis but with playing only a selection and windowing it\ +the stored wave-table could be a piece of bird-call and you could play a piece by feeling it - i.e. create a "haptic-landscape" that let's you feel what part of the wave you are on.} \ No newline at end of file diff --git a/software/apps/M&MStudioBV/PluckOverlap/PluckOverlap.ino b/software/apps/M&MStudioBV/PluckOverlap/PluckOverlap.ino new file mode 100644 index 0000000..aa3e5ee --- /dev/null +++ b/software/apps/M&MStudioBV/PluckOverlap/PluckOverlap.ino @@ -0,0 +1,55 @@ +// Pluck over-lap +// BV 3 Feb 13 +// one pluck at x=512 + +int x, fout, count; +float f; +float w = 50; //width of pluck +float h = 500; //height of pluck +float slope = h/w; +boolean forward = true; + +#include + +void setup(){ + MotorA.init(); + MotorB.init(); + Serial.begin(9600); +} + +void loop(){ + //x = analogRead(A0) - 512; + x = analogRead(A3) - 512; + if (forward){ + if (x<=0) f = 0; + if (x>0 && xw){ + f = 0; + forward = false; + Serial.println("pluck forward"); + } + } + else + { + if (x>0) f = 0; + if (x<0 && x>-w) f = - slope*x; + if (x < -w){ + f = 0; + forward = true; + Serial.println("pluck back"); + } + } + fout = int(f); + //MotorA.torque(fout); + MotorB.torque(fout); + if(count++>=0){ + count=-1000; // wait 1000 loops before print + Serial.print(x,DEC); + Serial.print(" "); + Serial.println(fout,DEC); + } +} + + + + diff --git a/software/apps/M&MStudioBV/PluckOverlapHalf/PluckOverlapHalf.ino b/software/apps/M&MStudioBV/PluckOverlapHalf/PluckOverlapHalf.ino new file mode 100644 index 0000000..1167de7 --- /dev/null +++ b/software/apps/M&MStudioBV/PluckOverlapHalf/PluckOverlapHalf.ino @@ -0,0 +1,51 @@ +//PluckOverlapHalf +// BV 3 Feb 13 +// one pluck at x=512 + +int x, fout, count; +float f; +float w = 50; //width of pluck +float h = 500; //height of pluck +float slope = h/w; +boolean forward = true; + +#include + +void setup(){ + MotorA.init(); + MotorB.init(); + Serial.begin(9600); +} + +void loop(){ + //x = analogRead(A0) - 512; + x = analogRead(A3) - 512; + if (forward){ + if (x <= - w/2) f = 0; + if (x > -w/2 && x< w/2) f = - slope*(x + w/2); + if (x > w/2){ + f = 0; + forward = false; + Serial.println("pluck forward"); + } + } + else + { + if (x > w/2) f = 0; + if (x < w/2 && x > -w/2) f = - slope*(x - w/2); + if (x < -w/2){ + f = 0; + forward = true; + Serial.println("pluck back"); + } + } + fout = int(f); + //MotorA.torque(fout); + MotorB.torque(fout); + if(count++>=0){ + count=-1000; // wait 1000 loops before print + Serial.print(x,DEC); + Serial.print(" "); + Serial.println(fout,DEC); + } +} diff --git a/software/apps/M&MStudioBV/ProcessingProfile/ProfileFx/ProfileFx.pde b/software/apps/M&MStudioBV/ProcessingProfile/ProfileFx/ProfileFx.pde new file mode 100644 index 0000000..332bfff --- /dev/null +++ b/software/apps/M&MStudioBV/ProcessingProfile/ProfileFx/ProfileFx.pde @@ -0,0 +1,126 @@ +// ProfileFx +// receives pos from Arduino +// +// +// int F[],x[i], shown as height F[x] "profile" +// then as slope of "terrain" dT = F[x] + + +// constrains x[i] sq(F[i]+100-mouseY)+sq(x[i]-mouseX)){ + ibest = i; + dist = sq(F[i]+100-mouseY)+sq(x[i]-mouseX); + } + } + ellipse(x[ibest],F[ibest]+100,20,20); + +text (Integer.toString(ibest), mouseX+10, mouseY-12); +text (Integer.toString(F[ibest]), mouseX+10, mouseY); +text (Integer.toString(x[ibest]), mouseX+10, mouseY+12); + + if (mousePressed == true){ + //now use ibest to move to mouseX, mouseY + x[ibest] = min(x[ibest+1],max(x[ibest-1],mouseX)); + F[ibest] = mouseY - 100; + if (mouseY < 0) F[ibest] = -100; + if (mouseY > 200) F[ibest] = 100; + } + +//plot "terrain" assuming 80 point separation of F[]'s + pushMatrix(); + translate(0,height/2); + + top = 0; + FF = F[0]; + for (i = 0; i < n; i = i+1) { + s = x[i+1]-x[i]+1; // increment used for plotting + inc = 0.01*(F[i+1]-F[i])/s; + for (j = 0; j < s; j = j+1) { + FF = FF + inc; + top = top + FF; // j increments of inc = F diff. + line(x[i]+j,height,x[i]+j,top); + } + } + popMatrix(); + + //receive pos from Arduino +while (myPort.available() > 0) { + myString = myPort.readStringUntil(lf); + if (myString != null) { + myString = trim(myString); + pos = int(myString); + } + } + // draw pos cursor + stroke(150); + line(pos,200,pos,800); + +} + +void keyPressed() { + if (key == CODED) { + if (keyCode == UP) --F[ibest]; + if (keyCode == DOWN) ++F[ibest]; + if (keyCode == RIGHT) ++x[ibest]; + if (keyCode == LEFT) --x[ibest]; + } +} + + diff --git a/software/apps/M&MStudioBV/Pulse/Pulse.ino b/software/apps/M&MStudioBV/Pulse/Pulse.ino new file mode 100644 index 0000000..1df2328 --- /dev/null +++ b/software/apps/M&MStudioBV/Pulse/Pulse.ino @@ -0,0 +1,20 @@ +//"Pulse" - small duration positive then negative force +// parameters: F1, T1, D1, F2, T2, D2 +#include + +void setup(){ + MotorB.init(); +} + +void loop(){ + //for (int i; i < 512; i + 100){ + MotorB.torque(10); + delay (20); + MotorB.torque(0); + delay (150); + MotorB.torque(-50); + delay (40); + MotorB.torque(0); + delay (750); + //} +} diff --git a/software/apps/M&MStudioBV/Pulse_Beat/Pulse_Beat.ino b/software/apps/M&MStudioBV/Pulse_Beat/Pulse_Beat.ino new file mode 100644 index 0000000..6d5a4d5 --- /dev/null +++ b/software/apps/M&MStudioBV/Pulse_Beat/Pulse_Beat.ino @@ -0,0 +1,34 @@ +//"Pulse" - small duration positive then negative force +// parameters: F1, T1, D1, F2, T2, D2 + +#define BIT_DEPTH 12 + +#include +#include + +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); + //} +} diff --git a/software/apps/M&MStudioBV/ReadA0A1/ReadA0A1.ino b/software/apps/M&MStudioBV/ReadA0A1/ReadA0A1.ino new file mode 100644 index 0000000..6b9ccaa --- /dev/null +++ b/software/apps/M&MStudioBV/ReadA0A1/ReadA0A1.ino @@ -0,0 +1,17 @@ +//read position A0 FSR A1 + +void setup(){ + Serial.begin(9600); + pinMode(A0,INPUT); + //for FSR + pinMode(A1,INPUT); + digitalWrite(A1,HIGH); + pinMode(4,OUTPUT); + digitalWrite(4,LOW); +} + +void loop(){ + Serial.print(analogRead(A0)); + Serial.print(" "); + Serial.println(analogRead(A1)); +} diff --git a/software/apps/M&MStudioBV/WallPluck_in/WallPluck_in.ino b/software/apps/M&MStudioBV/WallPluck_in/WallPluck_in.ino new file mode 100644 index 0000000..b763017 --- /dev/null +++ b/software/apps/M&MStudioBV/WallPluck_in/WallPluck_in.ino @@ -0,0 +1,54 @@ +//Wall +//need some mass so it "bounces"? + +#include +#include + +int x; +boolean inside; +int Fout; +int wave; +int Fmax = 4023; + +void setup(){ + Serial.begin(9600); + MotorA.init(); + + Music.init(); + Music.setWaveform(0);//8bit 0 = sine. + Music.setGain(0.0f); + Music.setFrequency(200); +} + +void loop() { +// waiting for "return" or "line-feed" +while (Serial.available()) { + wave = Serial.parseInt(); + if (Serial.read() == '\n') { + Serial.print("I received: "); + Serial.println(wave, DEC); + if (wave > 16) wave = 16; + if (wave < 0) wave - 0; + Music.setWaveform(wave); + } + } x = analogRead(A0)-512; + if(x < 0){ + Fout = -20*x; + MotorA.torque(Fout); + Music.setGain(1.0f); //contact silences music? + //Music.setGain(float(x/200)); + inside = true; + } + else{ + if (inside){ //first time outside + inside = false; //start note + Music.setGain(1.0f); + } + if(x>10){ + Music.setGain(0.998f*Music.getGainFloat()); + } + } +} + + + diff --git a/software/apps/M&MStudioBV/WallPluck_out/WallPluck_out.ino b/software/apps/M&MStudioBV/WallPluck_out/WallPluck_out.ino new file mode 100644 index 0000000..ce52cb7 --- /dev/null +++ b/software/apps/M&MStudioBV/WallPluck_out/WallPluck_out.ino @@ -0,0 +1,54 @@ +//Wall +//need some mass so it "bounces"? + +#include +#define BIT_DEPTH 8 // gives us 16 Waveforms + +#include + +int x; +boolean inside; +int Fout; +int wave; + +void setup(){ + Serial.begin(9600); + MotorA.init(); + + Music.init(); + Music.setWaveform(1);//8bit + Music.setGain(0.0f); + Music.setFrequency(200); +} + +void loop() { +// waiting for "return" or "line-feed" +while (Serial.available()) { + wave = Serial.parseInt(); + if (Serial.read() == '\n') { + Serial.print("I received: "); + Serial.println(wave, DEC); + if (wave > 16) wave = 16; + if (wave < 0) wave - 0; + Music.setWaveform(wave); + } + } x = analogRead(A0)-512; + if(x < 0){ + Fout = -20*x; + MotorA.torque(Fout); + Music.setGain(0.0f); //contact silences music + inside = true; + } + else{ + if (inside){ //first time outside + inside = false; //start note + Music.setGain(1.0f); + } + if(x>10){ + Music.setGain(0.998f*Music.getGain()); + } + } +} + + + diff --git a/software/apps/M&MStudioBV/motortestM/motortestM.ino b/software/apps/M&MStudioBV/motortestM/motortestM.ino new file mode 100644 index 0000000..9c97c80 --- /dev/null +++ b/software/apps/M&MStudioBV/motortestM/motortestM.ino @@ -0,0 +1,22 @@ +//motortest +//.5 sec forward, .5 sec back + +#include + +void setup() +{ + MotorA.init(); + MotorB.init(); + MotorA.torque(40); // small force for Plank + MotorB.torque(200); // need 200 for Fader +} + +void loop() +{ + MotorA.direction(FORWARD); + MotorB.direction(FORWARD); + delay(500); + MotorA.direction(BACKWARD); + MotorB.direction(BACKWARD); + delay(500); +} diff --git a/software/apps/M&MStudioBV/plotOsc/plotOsc.pde b/software/apps/M&MStudioBV/plotOsc/plotOsc.pde new file mode 100644 index 0000000..fd67978 --- /dev/null +++ b/software/apps/M&MStudioBV/plotOsc/plotOsc.pde @@ -0,0 +1,27 @@ +// step response of second order system +// m mass, k spring, b damping + +float xPos = 0.0; +float yPos = 0.0; +float xVel = 0.0; +float T = 0.1; +float koverm = 0.1; +float boverm = 0.01; + +int x, y; // variables at mouse- and screen-resolution + +void setup() { // setup() runs once + size(800, 500); + frameRate(30); +} + +void draw() { // draw() loops forever, until stopped + xPos = width/2; + xVel = 0.0; +background(204); + for(int y=0; y < height; y = y +1) { + xVel += koverm * (mouseX - xPos) * T - boverm * xVel; //a=F/m + xPos += xVel * T; + point(xPos, y); + } +} diff --git a/software/apps/Motor/pos_FSR_AB_test/pos_FSR_AB_test.ino b/software/apps/Motor/pos_FSR_AB_test/pos_FSR_AB_test.ino new file mode 100644 index 0000000..22a3294 --- /dev/null +++ b/software/apps/Motor/pos_FSR_AB_test/pos_FSR_AB_test.ino @@ -0,0 +1,30 @@ +//position and force reporting +//sends A0 (MotorA), A1 (ForceA) +//sends A3 (MotorB), A4 (ForceB) +// to Serial Monitor + +void setup() +{ + Serial.begin(9600); + //set up for FSR A1 to D4 + pinMode(A1,INPUT); + pinMode(4,OUTPUT); + digitalWrite(4,LOW); + digitalWrite(A1,HIGH); //internal pull-up + //set up for FSR A4 to D5 + pinMode(A4,INPUT); + pinMode(5,OUTPUT); + digitalWrite(5,LOW); + digitalWrite(A4,HIGH); //internal pull-up +} + +void loop() +{ + Serial.print(analogRead(A0)); //positionA + Serial.print(" "); + Serial.print(analogRead(A1)); //positionA + Serial.print(" "); + Serial.print(analogRead(A3)); //positionA + Serial.print(" "); + Serial.println(analogRead(A4)); //forceA +}