Skip to content

16. Interface and application programming

Assignment

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

Learning outcomes

Interpret and implement design and programming protocols to create a Graphic User Interface (GUI).

nueval-Check List

Described your process using words/images/screenshots Explained the the GUI that you made and how you did it Outlined problems and how you fixed them Included original code (or a screenshot of the app code if that’s not possible)

What I did

This week I used the board I made for input and output to get data from sensor(peltier cell.) I used Arduino for sensing and sent it to Processing and made it visual. When I gave heat on peltier, blue bar length enlarged.

Overview

I used a board created for week 11(input device.)

Peltier cell(white rectangle) is detecting heat and generate electricity.The board detected it. Arduino send it to Processing by serial and Processing visualize the value received from Arduino.

This is how I connect the board, peltier cell(input device), and laptop.

Here’s the demo video

Although I could visualize data from peltier cell with the blue bar on Processing but it vibrates frequently as you can see on the video. I assume this is the noise from electric board. I’ll deep dive how I can solve this and also research if I can solve this on software.

Arduino code

#include <SoftwareSerial.h>
#include <Servo.h>

SoftwareSerial mySerial(0, 1); // RX, TX
Servo servo;

int analogPin = 7; 

int val = 0;
int thresh = 550;

void setup() {
  pinMode(7, INPUT);
  pinMode(8, OUTPUT);
  mySerial.begin(9600);  
}

void loop() {
   val = analogRead(analogPin);   
   mySerial.println(val);
   delay(100);

  if(val > thresh) {
    digitalWrite(8, HIGH);
    delayMicroseconds(100);
    digitalWrite(8, LOW);
    delayMicroseconds(100);
  }
}

Processing Code

import processing.serial.*;

Serial myPort;  
float val; 

void setup()
{
  String portName = Serial.list()[1];
  myPort = new Serial(this, portName, 9600);
  size(480, 200);
  fill(0,255,0);
}

void draw()
{
  if (myPort.available() > 0) 
  {
  val = myPort.read();
  delay(100);
  }  
println(val);
fill(0,0,0);
rect(0, 0, 480, 200);
if (val > 40){
  fill(0,0,255);
  rect(0, 0, (val-40)*20, 200);
  }
}

Files

Processing File Arduino File