# Volume and motion

**URL:** <https://discourse.processing.org/t/volume-and-motion/14186>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [September 24, 2019, 9:46pm UTC](https://discourse.processing.org/t/volume-and-motion/14186 "2019-09-24T21:46:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![camilacaceresl](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@camilacaceresl](https://discourse.processing.org/u/camilacaceresl)\
**Post date:** [September 24, 2019, 9:46pm UTC](https://discourse.processing.org/t/volume-and-motion/14186/1 "2019-09-24T21:46:25Z")

</div>

I wrote a code where the amplitude of a audio input is mapped to the amplitude of a sin function. Right now is just controlling the position of ellipse on a screen but i want this motion to be applied to a drawing machine using an Arduino, possibly a servo motor.  
does any one have an example of how to convert this to using a motor?

```auto
import processing.sound.*;
Amplitude amp;
AudioIn in;

float s;//s is a map of the analyzer
float c;
float p;
float e;//speed
float range;
float v; //vertical movement

void setup(){
  size(1000,1000);
   amp = new Amplitude(this);
   in = new AudioIn(this, 0);
   in.start();
  amp.input(in);
  colorMode(HSB,360,100,100);

  s=0;
  e=0;
  v=0;
   background(c,100,100);
   noStroke();

}

void draw(){
  range=map(amp.analyze(),0,1,500,1500);
  e=e+1;
  p=map(sin(e),0,1,500,range);
  //c=map(amp.analyze(),0,.5,0,360);
  ellipse(p,v,5,5);
 // s=map(amp.analyze(),0,1,100,800); 
  v=v+.1;
  
  
  
}

```

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [September 24, 2019, 9:50pm UTC](https://discourse.processing.org/t/volume-and-motion/14186/2 "2019-09-24T21:50:03Z")

</div>

Welcome to the forums!

What exactly is your question?

---

<div class="post-metadata">

**Author:** ![camilacaceresl](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@camilacaceresl](https://discourse.processing.org/u/camilacaceresl)\
**Post date:** [September 24, 2019, 9:54pm UTC](https://discourse.processing.org/t/volume-and-motion/14186/3 "2019-09-24T21:54:22Z")

</div>

Hi! thanks,  
I am asking if someone knows or have an example on how to convert this to using a motor?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 27, 2019, 6:35pm UTC](https://discourse.processing.org/t/volume-and-motion/14186/4 "2019-09-27T18:35:33Z")

</div>

> [@camilacaceresl](#):
>
> a drawing machine using an Arduino, possibly a servo motor

I’d suggest looking at specific servo setups – it is much better to decide what hardware you want to target, specifically, before trying to get it to do what you want.

[https://discourse.processing.org/search?q=servo](https://discourse.processing.org/search?q=servo)

Are you sure that what you want is arduino? As opposed to a PC-connected AxiDraw, etc.?
