Interface & Applications Programming

New to Programming? Get Started Here:

It was suggested that I try a tutorial in the Processing programming language, since I haven't written any programs since the DOS and Cobol days a boring computer class in high school - yawn.

Our guru, Blair Evans, had a few Processing books on his desk, so I scanned through this one. Because it's written so concisely, I was able to scan through the introduction and 3 chapters, and write a short program (copied from an example in the book):

Saving your work in Processing

  • Click file then save => defaults to program's 'sketchbook' folder - SAVE often! with different names for version control.
  • click 'sketch' then show sketch folder to see the path of the sketch.
  • To create a new sketch in its own window => click file then new
  • Processing Resources:

    • precise data libraries:
    • troubleshooting:
    • Important Tip:

      For the Export Application option (under file), app folders are erased & re-created every time you use the command. Move the folder someplace else if you dont want it ERASED before you use the option again.

      Just typing in the code from the hardcopy book (2nd Ed. Make: Getting Started with Processing by casey Reas & Ben Fry, p. 195, Example 13-7: Read Data from the Serial Port) I noticed the error message appears at the bottom of the console stating a missing right curly bracket "}" until I completed the program:

    • You'll have to be mindful of how far to code while ignoring the error message.
    • Go too far and you'll spend more time than necessary trying to debug.
    • Not going far enough will keep you from completing your program in a timely matter.
    • You may need to go outside, stretch, eat or visit a fun site before you can debug the problem.
    • I hear dancing is the best way to get smarter AND fight off memory loss.
    • Whatever you decide, try not to waste too much time feeling frustrated, as those emotions won't magically write your program for you.
    • ***I wanted to try Javascript but was told that I would need to setup a server & blah, blah, blah to be fruitful in this assignment, so nah.***

      Programming in C:

      The strategy I used involved gathering various lines of Neil's C-code from the following assignment weeks to make my own, unique program:
      • Input Devices
      • Embedded Programming
      • Networking and Communications
        I used my FTDI/Button/LED board (also used in the week for Embedded Programming):

        Here's my traces:

        I wanted to program my board's lime green, LED to flash 3 times, when the button was depressed, while sending the letters 'd' (for down) and 'u' (for up) to the serial port interface. Essentially, the when the button is pressed down the LED will flash 3 times.

        Here's my C-code:

        When programming, I used the latest version of Ubuntu as my operating system and wrote the C-code in its g-edit text app.

        The LED didn't turn on after being programmed and the character output was weird when I checked in the Arduino serial monitor:

        Here's where I figured out that something wasn't quite right with my board:


        Because I had designed my board as both an input and an output device, I needed to also edit the make file, based on the micro-controller I decided to use, since I re-designed Neil's Button/LED board. The routine was being performed, but not as how I theorized... .

        The fuses needed to be set to handle the timing, the make file needed a line of code for the LED AND I had placed the wrong value resistor on my board. 499 ohm IS NOT 499K ohm

        • Removed the wrong value resistor with the heat gun and replaced it with the right one
        • MMCU (micro-controller) from 45 to 44 wherever that appears
        • F_CPU from 8 000 000 000 to 20 000 000 000
        • took code from fuses via the hello.FTDI.44.echo.c.make file from the embedded programming week and added it to the hello.button make file
        • ...then saved the make file
        • hooked up the cables & boards again
        • Programmed with the FTDI code first, then edited the LED routine
        • Opened the Ubuntu terminal, navigated to the make file
        • Programmed the fuses using the new code
        • unplugged the programmer, then the board
        • Here's the terminal output:

          Please note the following:

          The make file is specific to the processor.

          If your board layout doesn't match Neil's according to

          the make file, check and edit according to YOUR layout

          6pin headers have a programming orientation!!

          The ribbon cable housing must fit on the pin headers

          in the SAME DIRECTION.

          The terminal output for programming the fuses and loading the program on the micro-controller uses the external crystal (which is set by default to run at 1mhz, to run at 20mhz, fuses must be set) for timing.

          I loaded the corrected LED program to the board via my programmer.

          Here's my edited make file:

          I opened the serial monitor (Arduino IDE for Ubuntu), set the baud rate according to my C-code program:

        • [in purple text] #define bit_delay_time 102
        • [in blue text] //bit delay for 9600 with overhead
        • plug up board, press button
        • the right characters appeared
        • Another note on Make Files:

        • Every time you program your board, unless you change your make file,
        • use the same programming line - for me it was:
        • sudo make -f Vics.hello.button.45make
        • program-usbtiny
        • Make sure your programmer/board shows up in the devices menu BEFORE you start
        • programming!
        • Programming in Python:

          I retrieved Python code lines from the the Input Devices week (via the communication program) using Neil's code as a template to create my own (as I did with the C-coding). I used the Ubuntu terminal to run my program, then the Arduino Serial Monitor to view the results.
          Here's where the Edited GUI Python Program Worked:

          Here's my Python Program:

          Hero Shot

          This video shows the results edits my Python code found above:

        • changed the background color from white to red
        • changed the button name from 'quit' to ' shut it down'
        • changed the font size from 10 to 64
        • Back to Processing:

          So instead of a character appearing when the button is pushed, a star appears! If the button isn't being pushed, no star. If the button is held down, the star is animated and moves with the frequency of the light!
        • The serial port name was changed outside of using example codes from the hardcopy book => Make: Getting Started with Processing.

          Here's the results: