Interface & application Programming

Introduction

In this week we were introduced to different softwares that will help us to write an application that interfaces a user with an input &/or output device.




Processing

For this week, i will be using the processing software,which is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. I will also be connected it to Arduino for the main code. This Tutorial helped me alot since it is my first time to use this software. One example from the tutorial i began with before i start with my week's task,is shown below:
  • Open a new sketch (the looks and the tabs are quite similar to Arduino which made it easier to navigate).
  • Import Serial Library (import processing.serial.*) which is used here to find a way to listen to what our Arduino sketch is sending.
  • Get the port number and add it next to the command>> Serial.list()[here]
  • Complete the code by an if statement to receive data from arduino if serial is available
  • After Uploading Both the arduino and processing code, the results should look similar to what's on the left.




  • Arduino Built In LED

    First, I started with testing the serial commands to turn on/off the led by simply typing inside the serial monitor the letter "t" in my case. This was pretty straight-forward but to give us an idea of how we can send the signals to arduino from the laptop and specifically the serial monitor.
    Then, I created a Box in Processing which when clicked can turn on the LED on the arduino by simulating what i did in the first step where i sent the letter "t" to the serial connected ( the serial port number must be known) to turn on the led. To do this I imported ControlP5 library using use the Library Manager from the menu under Sketch → Import Library → Add Library and searched for ControlP5. The reason why we chose this library is that becuase it contains controllers to build a graphical user interface on top of processing sketch to include Sliders, Buttons, Toggles etc. and can be easily added to a processing sketch, a complete list of features can be found here. Then the "cp5.addButton("Button")" was used to create the Box. On the arduino side, the same code was used as in the first step.
    Downloads

    Attiny 44 LED - Control from Processing

    The same steps will be used as in the previous part,but this time using Attiny44 connected using FTDI cable.
    From the arduino side, the same code will be used but with using Software Serial library since some ATtiny chips do not have direct support for hardware based serial and therefore the Serial object is unavailable, and changing the led pin number.
    As for the Processing code, the same code is used except the software baud rate is changed.
    Downloads

    Attiny 44 LED - Display on Processing

    Now, instead of controlling from processing, i will do the opposite by pressing the button on the board and displaying the status on Processing. Arduino code is again basic where this time we will write the if statement based on the logic states of the button and the output to led, and then using the command "mySerial.write(state to be sent)" to send status to the port. On the Processing side, the code is modified to receive the status of button from port and display certain message on a rectangular display, the commands to create it were really simple: background(#),textSize(#),textAlign(""),fill(),text("",#,#).
    Downloads


    Group Assignment

    For this task, we need to do the following:
  • Compare as many tool options as possible.
  • The link to the group assignment page is found here.


    Experience

    A very tough week where many options are given to create the application that interfaces us as users with an input &/or output device, even though i chose one software, it was a whole new experience and i look forward to explore it further more in the future.