Week 5 Documentation

I mentioned in my last post that one of my goals for this class will be to create a programmable camera mount to be used alongside Dragonframe for my first animation project in the second half of the semester. Given what I’ve seen of class schedules from previous years, I think that it would need to be ready by Halloween for a project due on the 7th (assuming that most classes follow the same schedule). Which means that, in addition to the PComp midterm, I need to take opportunities each of the next few weeks to take steps towards that goal. It’s going to be a challenge, but I’m hoping I can make it work.

Long term, there are three big things that I need my device to be able to accomplish –

1.     It needs to be able to take discreet, incremental steps based on a specified input run through a mathematical function.

2.     It needs to be able to transfer that input to a 360° motor, which has the ability to do real mechanical work.

3.     That motor needs to be able to move an entire camera along a single axis.

I don’t know how steps two and three are going to work right now, so I’m going to focus on step number one. I want to make sure that I have the programming ability to make it do step one. I’m going to keep a similar setup as last week, but instead of using an FSR to control the Servo I’ll be using a digital input. (The assignment for this week was to “review any of the labs that gave you trouble in the past,” so I figured I had some flexibility to do some work for a bigger project. Let’s call this Lab 2, but with a servo instead of a speaker.)


Ok, so just to get back roughly to the place where I left last week, let’s modify this code to look for an input that I give it.


So I just changed what had been an analog in from my FSR last time to an integer that I set manually, which I chose to call “stepValue”. Assuming that I wanted my stepValue to range from ten (set as an integer variable at the top of my code), then that value would map to a servo angle. In this case, mapping to an angle of 161.

Now for the function part. Right now, the motor moves in a straight line from 0° to °180. I want it to be able to “ease in” to its final position, similar to using a Bezier curve in After Effects to map variables. So instead of the curve of angle over time (or in this case steps) looking like this

Screen Shot 2018-10-09 at 2.36.31 PM.png

I want it to look like this –


So there are a couple of things that I need to figure out. First, how does a program like After Effects even make a function like this? And second, how do I translate that function to use with an Arduino?

For the first question, I checked on an online forum. The answer that I found was….

Screen Shot 2018-10-09 at 2.44.36 PM.png

A little more complicated than I had hoped it would be. I might need a refresher on my high school calculus. I’m sure Wikipedia can help.

Screen Shot 2018-10-09 at 2.59.28 PM.png

Um, I’ll just keep reading and maybe it will start to make sense…

Screen Shot 2018-10-09 at 2.59.20 PM.png

Ok, this ain’t happening. I can’t write this myself. Honestly, I don’t even know what I’m looking at when I check GitHub for answers. Fortunately, p5 has exactly the function that I’m looking for.

Screen Shot 2018-10-09 at 3.08.33 PM.png

And extra fortunately, the subject of this week’s videos was all about using serial communication to communicate across platforms. If we write some special fun code to get us an output along a Bezier curve in p5. So now I need to create a node in p5 that travels along a Bezier given an input -

Screen Shot 2018-10-09 at 3.41.25 PM.png

And here is where I hit a snag. I can get p5 to draw the Bezier, but I can’t get it to output the y-value for a given x input. I think for today I’ll just have to use a simpler formula that I arrived at with the help of an online graphing calculator

servoAngle = angleMax - (angleMax / (principle ^ stepValue))

servoAngle = angleMax - (angleMax / (principle ^ stepValue))


Which works well when plugged into the Arduino –

Screen Shot 2018-10-09 at 4.58.47 PM.png

So now I have a couple of accomplishments, and a couple questions. I have a device which successfully takes a function of my own making and translates it to the outside world. But I need to be able to generate a more complex function input in p5, and I still need to be able to transfer that to the Arduino’s input. And after that, I need to translate that into something that can move. Moving slowly, but moving forward.