Fab Academy 2014: Class Archive Fab Central

How To Make (Almost) Anything

by Tiago Figueiredo




Week 15: Interface and Application Programming


Hi everyone! On this week assignment we had to write an application that would interface with an input and/or output device. I have to say that I've been having many difficulties with this assignment. At week 10 everything turned out okay. I could visualize the output of the sensor in Python, but I had some problems trying to do so. The problem was based on some Python's dependencies not being installed properly and so I could not make the graphical bar move when I touched the sensor. Everything is okay now.


For this week I was having a problem of the same nature, but this time Processing had nothing wrong with its installation so whenever I tried to run a sketch on my board, nothing happened. After some tries, the sketch started to run but there was no visualization for it, only a black window with no graphical output. I don't even know what happened this time, but surely it was something like voodoo, because now processing is working with my board.


For this part of the assignment I simply ran one example sketch that we made at our Lab with the help of our instructor Ferdinand Meier and everything turned out okay. Here is a video of the working sketch:






Extra work!


I have to tell you the story on how this extra work came to be. I missed the Output Devices class, but in my mind that week was supposed to be Interface and Application Programming week, but I was getting my schedule from the wrong place. Since I missed class, I stayed all weekend at home learning the basics of Processing. After some days working with the software, I decided to make some sketches that, in my opinion are pretty useful.


I've done three different sketches: one about a grayscale, another about the use of a loop function to create a perfect grid, and last but not least a really simple sketch on how to work with strokeWeight. Each sketch has the feature of generating a PDF file for later use, like the lasercutter, for example. In fact, all my sketches were drawn thinking about the laser and how could I write some code that everyone can run and generate some PDF files to use with the machine. I must admit that I got fascinated by this possibility and so I worked on it.


I will now explain the sketches I've written for better understanding:



    Grayscale

  • In this sketch, I simple defined two variables for x and y so that I could later work with them. In the setup function I defined the size of the output window and the background color. After that there is a draw function where the variables come in hand, and the function draws the grayscale on the ouput screen divided in many vertical rectangles. To finish, there is a saveFrame that saves the output as a PNG on your sketch folder.

    • Loop Grid

  • This sketch has the name loop grid because the way the grid appears on the output window comes from the use of a loop that generates that grid. So, first of all the size of the output windows is defined and remember that this value can change to whatever you like, whatever suits your needs. After that comes the draw function and what it does is check the screen size and divides that size by a number and then draws a line across the screen. To finish, the same thing done on the previous sketch is done on this one as well, so a saveFrame is written so that it can generate a PNG file to your sketch folder.

    • Stroke Weight

  • On the last sketch, things could not be easier. Again comes the size definition, but this time there is no output window. This sketch was drawn as an application that will automatically generate a PDF file for later use. You can see that this time I didn't use the saveFrame but instead used inside the size definition to output as a PDF. To control the weight of the stroke on the sketch, just make use of strokeWeight and that weight will be visible on your output. Try with different settings and then go to you Lab's lasercutter and experiment with the file.




  • Project's Files


    Here you can download the sketch made with the help of my instructor:


    Processing sketch for the assignment


    Here you can download the extra sketches that I developed this week as well:


    Grayscale

    Loop Grid

    Stroke Weight



    Thank you for watching everyonre! Hope this documentation can be of any help

    Fablab EDP | Fab Academy | MIT | CBA