Understanding interface and application

WEEK13: INTERFACE AND APPLICATION PROGRAMMING

ASSIGNMENTS:

 

Individual assignment

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

   Group assignment

  • Compare as many tool options as possible
  • As interface and application programming was completely new to me, I have started with reading and exploring about what interface and application fundamentally means
  • By definition interface is "shared boundary across which two or more separate component of computer system exchange information".
  • Interface can be one way or two, which can only send/receive data and one can do both. Examples are mouse and microphone which can only send data one way. Whereas touchscreen send receive data altogether.

STEP01: Deciding what I wanted to do

  • After getting basic idea about interfacing and application, now I thought back to my final project where such controls I require.
  • Doing so I realize that I need a control where I can turn on and off heater to regulate require temperature for smooth extrusion of my pallet extruder machine.
  • So, I decided to make application where I can control cartridge heater of my final project board which I have designed and used during and input and output device week.

STEP02: Exploring MIT App inventor

  • As I was new to development of interface applications, I have researched few platform as suggested by Niel in lecture such as processing, python, java, app inventor etc.
  • But having no background of programming I decided to start with mit app inventor which was comparatively easy  to understand and make link between behind the screen component and math behind any application.
  • MIT app inventor is browser based portal, so no need to download software in computer system, which can be accessed from here
  • I have referred online tutorial given by mit app inventor website. also the get started guide was very helpful to start with.
  • As I intended communication between board and phone by bluetooth, very good tutorial I referred is here, where each components are explained in detail.

STEP03: Step by step app development

  • Once I open inventor I signed up through my Google account.
  • And first screen asked me to create project, so I have created one with name "week13Interfacing"
  • And first screen asked me to create project, so I have created one with name "week13Interfacing"
  • After creating project first thing I have got on screen is designer viewport, where I can design and arrange interface of my application, without worrying about inside code. I have selected horizontal arrange
  • Once I got horizontal arrangement, I have chose List Picker, and resize it to my requirement from right side menu bar.
  • In order to upload image for list picker I have to upload all the require images, after that I can use  uploaded image for list picker and buttons.
  • After that I have created two button by choosing it from left panel, in order to create on and off buttons. And select image for each buttons.
  • One important thing we have to select here is Bluetooth Client, and Clock, in order to establish wireless connection to communicate with inteded hardware.
  • Once I got ready with general formating and basic layout of my buttons, texts and images, now I should shift to Block, by clicking on upper right corner.
  • Block is to create algorithmic pattern to take information and process it such way so that it can display desired value on interface
  • In Block first thing we have to choose is "before picking" list picker, and make an input by connecting with bluetooth access name. so that user can pick one establish connection.
  • Once bluetooth connection establish it should make sure connection feedback is given by app. so for this I have chose If and Than loop to display respective value of bluetooth connection.
  • Next step is to display and execute value while pressing on and off button, for that I chose list pickeer for button and set values for text to display while on and off.
  • Here I have made mistake, which later I have realized that I havent specified value for ON and OFF
  • After completing Block connections I went back to Designer view and made some changes to make it look good. And I have exported apk file to install in my android device.
  • Once app is installed in my device I checked it ny connecting arduino, just to confirm weather app is working or not, so in next step I can connect it with my board.
  • I found that on serial monitor app was sending string of reapeated data, after researching about proble I found that, its because that I havent specified ON and OFF value, something like 0 and 1, that can be used to do specific operation.
  • So, that I have resolved it.

STEP04: Testing app with Arduino before use it for my board

  • In order to perform on off task I have chose arduino just to confirm weather my app is  functional or not.
  • So first task here is to write program to turn on and off led of Ardiuno by app which I have created.
  • So, I wrote program for LED blinking with the help of Ardiuno IDE example code, and modified it.

#include <SoftwareSerial.h>

 

SoftwareSerial mySerial(8,9);//rx,tx (blutooth tx,rx)

void setup() {

  mySerial.begin(9600);

Serial.begin(9600);

pinMode(13, OUTPUT);

}

 

void loop() {

 if(mySerial.available()>0)

  {

    int g = mySerial.read();

   Serial.println(g);

   if(g==1)

   {digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)13

  delay(1000);                       // wait for a second

  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);

  }}

 

}

 

  • Once code gets ready, I have connected Ardiuno with computer, and select required board, processor, and programmer to upload code.
  • After that I have uploaded code. (It gave me 3 4 time error to upload code because of loose connections of SCK and Reset pin. Also one time syntax error).
  • I have connected bluettoh module E47533 with ardiuno by making connection between VCC, GND, Rx and Tx pins.
  • Bluetooth module blinks LED when power is supplied.
  • After making right connections, I have opened my app and turned bluetooth and paired with HC-05 which is my bluetooth module.
  • Once paired and connected, my app shows, "Its connected" message.
  • Then I tested LED on and off  from my app, which can be seen in below video.
  • Then I tested LED on and off  from my app, which can be seen in below video

STEP05: Programming and testing the app with my board for heater control

  • Once my app is working fine, I shifted to write program for my board where I can control heater from my application.
  • Now I have to read serial monitor data and execute task (on and off) based on value sent by app which is 0 and 1.
  • So with above logic I wrote following program. It didn't work initially due to few syntax, closing, and definition error. But with 2 to 3 attempts I was able to work it out.

 #include <SoftwareSerial.h>

 

SoftwareSerial mySerial(8,

);//rx,tx (blutooth tx,rx)

void setup() {

  mySerial.begin(9600);

Serial.begin(9600);

pinMode(7, OUTPUT);

}

 

void loop() {

 mySerial.available();

 

    int g = mySerial.read();

   Serial.println(g);

  if(g==0)

   {

    digitalWrite(7,LOW);

  }

 if(g == 1)

  {digitalWrite(7,HIGH);   // turn the heater on (HIGH is the voltage level)13

// turn the heater off by making the voltage

}}

  • Now I have connected my board to FabISP, to upload the program in board. And uploaded code by ISP.
  • Once it got uploaded, I have connected bluetooth module with VCC, GND Rx and Tx pins  of board and check my app.
  • Once it got uploaded, I have connected bluetooth module with VCC, GND Rx and Tx pins  of board and check my app. Also I have connecte heater with my baord.
  • As final step I have open my application in phone and turn on bluetooth. Here I have redesigned my app bit to make it look better.
  • Once I connected my app via bluetooth to my board, I have decided to check functionality of app with LED which is connected with my heater. This test can be seen in below video.
  • Final test I have done to Turn ON and OFF to cartridge heater connected in my board to control required temperature. This demo can be seen in below video.

LEARNING CONCLUSION

 

  • After exploring and working through this week, I have understood what interface means and why we use it.
  • Secondly, I understand logic behind all kind of interfaces and application, for example what math is behind when we press button and click on screen.
  • Now  I am confidant to make basic app with MIT app inventor platform, its really nice platform for newcomer to coding like me.

ORIGINAL FILES

 

  • I am attaching here original files for this week as package, which includes  original source file of application I have developed, apk file, and program code.
  • This can be downloaded from here

INDIVIDUAL CONTRIBUTION TO GROUP WORK

 

  • For this week's assignment I have done comparison between different types of interface development platforms such as Processing, Python, MIT App inventor, JavaScript and Grasshopper/firefly.
  • Basically I have studied to get overview of different types of interface platform to check its functionality and features.

Click here to see this week's group assignment work in detail

Go to Week 14

Go to Weekly work page

2018 | Tanvir Khorajiya