Suddenly, worlds collide. Processing + Arduino together! In the past, I have worked with serial communication on a couple projects while I was learning how this all works. And in a coincidence of awesome timing, I used the basic code of the lab to begin doing some research on our midterm!

Past Serial Exploration

I used Xbee, Processing & an Arduino w/ relay to remotely unlock the apartment building. In the end I opted to buy a pre-made version, Lockitron, mostly for the already finished backend web components [a relay based version, not the new product]. But it essentially works in the exact same way as my setup. If I could go back in time, I would likely have done this one myself rather than buying the product. Also, how was that only a month ago?!

 Serial communication took place between processing and the Xbee and between the second Xbee and Arduino.

Serial Lab & Pre-Midterm Exploration

You use CoolTerm to chat with Xbees when they are in a serial command happy mode. So I've screwed around with this before. I still took a look at what the Arduino was saying:

Graphing a Accelerometer

Last week I picked up an accelerometer at the NYU bookstore. I thought it would be interesting to get started on the midterm and experiment with graphing the sensor.  Although I didn't realize it at the time,  getting data from all three axis is similar to next week's lab,  Multiple Serial Output.

Using the sketch we made in class, I began by logging the output of the accelerometer. When I got to the elevator, I decided to ditch X and Y as they are not relevant to the up and down motion of the cab. The graph on screen was interesting, but not very useful. Rather than taking the time to adjust the drawing, I stuck the output into google docs.

Reviewing the graph, I learned that the movement of the elevator is not very significant. The ADXL335 has a 3 g resolution and the elevator movement never gets close to that intense.  Nonetheless, there was enough of a value change to experiment with reading the accelerometer data and figuring out when the elevator starts/stops moving and in what direction.

I was able to pretty reliably get processing to take in the accelerometer data and report if the elevator started moving up or down and when it stopped. Here's the code that I was using to log the data (basically the same as in class).


Later I was able to get processing to report when the elevator started or stopped moving and in what direction the motion occurred.


Note: I edited the code so it works with a potentiometer, just so it's easier to play with. If you use this with an accelerometer, you'll need to update the values that make the downcounter & upcounter trip. You'll also need to adjust the number of counts on the down & up counter that are needed to start the down or down sequence.
This probably wasn't the most efficient way of doing this, but it at least shows that everything can work!


Update: I should have set  the analog reference because my accelerometer runs at 3.3v. That would explain the resolution problems.

© 2017. Some Rights Reserved.

Ghostium Theme by @oswaldoacauan

Proudly published with Ghost