Interface and Application Programming

Tasks of the week

  • Write an application that interfaces with an input &/or output devices that you made.
  • PROCESSING

    In this week's task, our objective is to design an application or an interface which allows users to interact with the microcontrollers which we designed by ourselves in previous weeks. To fulfill the requirements of this task, we have plenty of options like MIT APP inverter, Python, Processing, and many others. Without any hesitation I jumped on processing, as MIT APP inverter was also very new to me. Processing is a flexible software, sketchbook, and a language for learning how to code within the context of the visual art. Using of processing has many benefits, few are listed below:

    PROCESSING i3 logo


    Serial Library: The Serial library reads and writes data to and from external devices one byte at a time. It allows two computers to send and receive data. This library has the flexibility to communicate with custom microcontroller devices and to use them as the input or output to Processing programs.

    After downloading the "processing", I intended to use attiny 44 based microcontroller using LCD, as I designed such a board in week 12. I want to display digits on LCD by writing the data in processing. I interfaced LCD in microcontroller in output devices week and I will use LCD in my final project too in atmega32U4. Here in this week, I am again using LCD through attiny44 board.

    Rx /Tx: I did not connect pin no. 4 and 5 of FTDI connecter in week 12, because there was not use of these pins in that time. But here in this week these pins are in use, so by using jumper wires I connected pin no. 4 and 5 of the FTDI header, Rx and Tx respectively to the two unused pins of attiny 44 like pin no. 5 and 6 of the attiny44 IC. In week 12, I connect these two wire in a empty header for future use, so here is the use of these two pins.

    manually connected 'RX' pin and 'TX' pin on shown drills through jumper wires in previous week's board of output devices.


    PROCESSING code:

    import controlP5.*;
    import processing.serial.*;
    Serial myPort;
    ControlP5 cp5;
    String text;
    void setup() {
    size(400, 400);
    cp5 = new ControlP5(this);
    cp5.addTextfield("Write here").setPosition(100, 100).setSize(100, 50).setAutoClear(false);
    cp5.addBang("Send to LCD").setPosition(200, 100).setSize(100, 50);
    // for serial communication
    printArray(Serial.list()); //prints all available serial ports
    myPort = new Serial(this, "COM9", 9600); //i have connected my board to COM9 port
    myPort.write('c');
    }
    void draw() {
    background(150);
    text("Interface assignment - Nadir Ali", 80, 30); //"text", x coordinate, y coordinate
    }
    void Submit() {
    println();
    print("this is the text/digit you typed :");
    text=cp5.get(Textfield.class, "a").getText();
    //myPort.write(65);
    print(text);
    }

    While playing above code, it needs including of library controlP5. So, go to Sketch, Import Library, Add library, then a windows will appear, there is a search box. Write controlP5 and install it.

    Adding asked library. Go to 'Sketch', 'Import Library', 'Add Library', then write the required library name in search box given on top.


    Library 'controlP5' added successfully.


    By playing code with valid port number and installing libraries and instaling them, here appears a window, where user types anything then that will display on LCD as it is. I typed digits 1 then play it, it appeared on LCD, then typed 2, then 3 and 4. These all typed digits appeared on LCD as shown in below photo.

    Interfaces of the "Processing", "Arduino", and final layout page of the application.


    Texts written on 'processing' on laptop, result is displayed on LCD.


    Learning outcomes

    Download all files from here

    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.