Greetings, here lies my work-log at

______ _ ___ _ _____ _____ __ ______ | ___| | | / _ \ | | / __ \| _ |/ | |___ / | |_ __ _| |__ / /_\ \ ___ __ _ __| | ___ _ __ ___ _ _ `' / /'| |/' |`| | / / | _/ _` | '_ \| _ |/ __/ _` |/ _` |/ _ \ '_ ` _ \| | | | / / | /| | | | / / | || (_| | |_) | | | | (_| (_| | (_| | __/ | | | | | |_| | ./ /___\ |_/ /_| |_./ / \_| \__,_|_.__/\_| |_/\___\__,_|\__,_|\___|_| |_| |_|\__, | \_____/ \___/ \___/\_/ |_|


interface and application programming



index


Assignment requirements



intro / overview

Coming from a design background, i was suggested to experiment with processing, with all the familiarity gained with the arduino IDE, processing would be nice - they said .

In the end, i managed to interface with my LM35 input sensor and create a very wobbly ellipse that would move across a range of detected temperatures

I used OBS (Open Broadcasting Studio) for this following demo



processing workflow

Start a new sketch >> Open an example sketch - serial read >> mpdify the code >> Map the serial data from the sensor >> Render an ellipse in a GUI with it's centre moving across a specified range of input values



GUI breakdown

It's a simple range, within which the ellipse moves across to denote a range of 29 to 70 degrees celsius

Network

comms happen over TX, RX over a 5v FTDI wire RS232 protocol



problems faced

The problem was that the temperature increase was only uptil 60-70, which wasnt producing enough movement in the interface.So, the value was mapped to 200, which solved it



'Code'

/Code for processing sketch

 
/**
 * Simple Read for LM35 sensor
 * 
 * I modified the 'simple read' sketch
 * increased the mapped range to 200 to increase the visual change in motion for this example
 
 */


import processing.serial.*;

Serial myPort;  // Create object from Serial class
int val;
void setup() 
{
  size(200, 200);
  // I use an Ubuntu OS based laptop
  // and the correct portname is ttyUSB0
  // 
  // 
  String portName = Serial.list()[1];
  myPort = new Serial(this, portName, 9600);
}

void draw()
{
  background(0);  

  if ( myPort.available() > 0) {  // If data is available,

     val = myPort.read();         // read it and store it in val
    println(val);
  }
  val=(int)map(val, 30, 70, 0, 200);
  ellipse(val, 10, 20, 20);
}




/Code for sensor board

 
    #include //library to replace hardware serial

SoftwareSerial myserial(3, 4); // TX and RX pins (transmit and recieve)

#define tempPin A1 //Defining the pin A1 as the data pin
int val; 
void setup()
{
  myserial.begin(9600); //serial begins at 9600 baud rate
  pinMode(A1, INPUT);  //pin A1 becomes an input now
}

void loop()
{
  val = analogRead(tempPin); 
  float mv = ( val / 1024.0) * 5000; //mapping analog values to relevant temperature readings
  float cel = mv / 10; 
  float farh = (cel * 9) / 5 + 32;

  myserial.print((char)cel);  
  delay(10); 
}
    
    


conclusions

A relatively simple undertaking but was filled with a wierd sense of gratification. To visualise abstract ranges is fun. I would want to go further into computer graphics and systems like OpenGL




File Downloads