WEEK 12 - Interface and Application Programming


INTRODUCTION

at first I had no experience in Interfacing prgramming previously(exept MIT Inventor app), So I got an exciting journey while trying to learn...let's go I think these weeks will never be forgotten, we are in the forth month and the world is still under pandemic, but we are trying to help with digital fabrication, and i think we have done a good job so far.

Assignment Description

    individual assignment:

  • write an application that interfaces a user with an input &/or output device that you made

The Idea


  • I need to make an indecator for my output device
  • I have a little bit experiance in MIT app inventor, so I decided to use processing
  • Download Processing from here
  • also you need to ArdinoIDE from here
  • this is useful toturial for beginners Processing tutorials

Lets start


  • open processing
  • We can divide the window into two areas: void setup() & void draw()
  • this is like Arduino, so:
  • in void setup(): put your setup code here, to run once(initialization code)
  • in void draw(): put your main code here, to run repeatedly
  • I used Meter lib, you need to install it

Coding


The first code

  • Just see how the library works
  • before void setup()
    • to import your lib: import meter.*;
    • to call functions: Meter m;
    • if you need to import image: PImage img;
  • in void setup():
    • put the size of image: size(600, 400);
    • Load the image into the program: img = loadImage("Lungs.jpg");
    • to initialize the lib and set its size: m= new Meter(this, 80, 50);
  • in void draw():
    • to make your image transparent: tint(150, 150);
    • to generate a random number: int value =(int)random(0,10);
    • to show the changed variables: m.updateMeter(value);
    • to make it stable: delay(1000);

The Idea


The final code

  • before we start, I used the Arduino code that i used for output
  • to connect between Arduino and Processing:
    • in Arduino, print the value: Serial.print(value);
    • in Processing use this with change the port name: port = new Serial(this, "COM4", 9600);
  • Tricks:
    • Ensure that the correct values ​​are set: String[] scaleLabels = {"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"};
    • Ensure that the correct Port ​​are named
    • recive your value as a: String

all documents here