Exercise 12 - Interface and Application Programming

Weekly Assignment

Group Assignment:

Compare as many tool options as possible

Individual Assignment:

Write an application that interfaces with an input &/or output device that you made

Group Assignment

Firefly

Firefly is a plug-in (for Grasshopper, which is a plug-in for Rhino) that gives us a way to visually program through the Grasshopper environment (which is good if you're into that kind of thing-if you're not don't use it as it can be super confusing). Furthermore...
  • it uses firmata to communicate
  • each node can be written in arduino code
  • it allows you to parametrically define or alter inputs to the microcontroller
  • it translates physical interfaces to transformations in the CAD program
  • We hooked up a potentiometer that moved a sphere in Rhino, which was the CAD program.

    Unreal

    Unreal is a game engine for world building. While it greatly interested us and we looked at some of the tutorials on the website, we couldn't find anything that would teach us how to interface with a microcontroller. So the extent of our Unreal experience was downloading it and perusing some of the tutorials. We might look into it more when there is more time. A search on the fabacademy archives yielded people with the same opinion as us. So it seems this is a generally difficult program to learn (especially in a week).

    Processing

    Processing seems very open ended with many options for creativity. What's more, there were many helpful tutorials and examples on the website that made learning it much easier than the other programs. Basically, the learning curve was much less steep, though we know there are many more options for implementing our creativity than that which we have already done (which is super exciting).

    Individual Assignment

    After looking through the different intreface applications in our group project, I did decide to go with Processing. (Also, Neil's quote in the video, which I explicitly wrote down was "If you are feeling overwhelmed" Processing is what you should use. That sounded about right to me...)

    I went to the Processing website and downloaded the Processing Application. I had NO prior knowledge or experience, so I decided to start with some tutorials. There are TONS of useful tutorials at this site, and I decided to start with the very basic ones.

    I started with "Hello Processing", an hour long BASIC tutorial that really helped me see what Processing was capable of and how to write basic Processing commands. The presenter of the tutorial used a lot of commands that I didn't even know existed (like "MousePressed" as a state in the Processing Canvas) and I started wondering if there was a list of such commands. Turns out there is, and I found it here. Every command you could ever need and more! I worked through the hour long tutorial and learned a ton. (I declined to print the "Hour of Coding" certificate that I earned, though.)


    I attempted to get Processing to draw a PokeBall, but I forgot they were white on the bottom.


    I then started thinking about how to make Processing work with Arduino, so I searched for a video on that. I watched one short one but I think I might also watch another later.


    Tutorial on Serial Communication of Processing with Arduino


    At this point, I thought I was ready to start trying to do some interfacing. (Reader, I was wrong.) I decided to start with some examples. I quickly realized (labmate Will Rudolph helped) that Firmata might be helpful, so I downloaded and installed the Firmata library into Processing. Firmata came with some examples for input, and output, so I decided to try to work through those. First was the input example. I hooked up a light sensor to my board and used the default Processing example. That worked and made blue circles that got bigger and smaller depending on how much light was incident on the sensor. I decided to tweak it a bit to see if I could make it do something different. I learned how to change the circles to rectangles and I changed the number of rectangles that there were and the color of the fill. Videos of this process working are below.


    The default code I originally did so that I knew it worked


    The light sensor changing the screen with three yellow rectangles now, instead of six blue circles


    Next, I decided to try going the opposite way, where something that I changed or accessed on the computer screen changed something on my board. I hooked up 3 festive LEDs on my board and downloaded the default Processing example for Output. It worked. When I clicked on the blue rectangles with my mouse, the LEDs would toggle on and off. I again modified the code just to make sure that I could, by changing the blue rectangles to yellow circles. I also changed the size of the canvas that the circles were displaying on. I wanted to be sure I knew how to change the parameters as needed.


    The LEDs turning on and off from mouse clicks on the screen


    After working through the examples and changing and tweaking some things, I originally thought I was done. However, I didn't feel like I really grasped what was going on and I wasn't sure I could write something "from scratch" or even from a skeleton example, since I had just tweaked things before. I watched another video tutorial (linked below) that really made me feel confident I could so something. I should know by now that that feeling is a harbinger of doom.


    Tutorial on Serial Communication and Processing


    It turned out that the tutorial I watched was from 2011, for a much older version of Processing, and that things had changed quite a bit in the newer versions. However, I persisted, and working from parts of that video, and parts of another tutorial, I cobbled together something that worked!! I was so excited. My mostly original example uses a potentiometer hooked to my board that changes the background color of the canvas.


    The arduino code for the potentiometer


    The Processing code for the potentiometer to change the background color


    It works!!!


    Overall, this week was pretty interesting. I liked using Processing to interface with my board because it was cool to see that something outside of my computer made something happen on the screen, or vice versa.