Gautam Naidu

From: Information and Digital Design (2007-09)
National Institute of Design
PG Campus,
Gandhinagar, India
Contact: moc.liamg|ogolletni#moc.liamg|ogolletni

Assignment 1: Piet Mondrian
The Dutch artist Piet Mondrian (1872-1944) was a pioneer in abstract paintings. Each painting was worked and reworked, built layer by layer toward an equilibrium of form, color, and surface. Mondrian named his style "neoplasticism." That is how he translated his own Dutch phrase nieuwe beelding, which also means "new form" or "new image." The style was based, he explained, on an absolute harmony of straight lines and pure colors underlying the visible world.
This consisted of a grid of vertical and horizontal black lines and the use of the three primary colours.[http://en.wikipedia.org/wiki/Piet_Mondrian. Using Processing Language, a programming language and (I.D.E.) integrated development environment for visual design, we can learn the basics of programming in a visual context, and to serve as the foundation for electronic sketchbooks.
Reference: http://www.artmuseums.harvard.edu/mondrian/career/index.html

Screenshots of the output is shown below:
flickr:2830996675

The processing code is as follows:

/*
Create the "compilation of red, blue and yellow" work of Piet Mondrian.
*/
void setup()
{
  size (400,450);
  background(255,255,255);
}

void draw()
{

  noStroke();
  //fill colours
  fill(255,255,0);
  rect(190,0,150,40);

  fill(0,0,0);
  rect(340,0,60,80);

  fill(0,0,255);
  rect(0,180,30,170);

  fill(255,0,0);
  rect(340,430,60,20);

  //horizontal lines
  stroke(0,0,0);
  strokeWeight(7);

  line(30,40,350,40);
  line(0,180,30,180);
  line(0,350,340,350);
  line(340,430,400,430);

  //vertical lines
  line(190,0,190,40);
  line(30,40,30,350);
  line(340,500,340,0);
}

Assignment 2: Blink
We were introduced to the Arduino microprocessor. Arduino is an open-source electronics prototyping platform based on flexible hardware and software. Used by designersit helps in creating interactive objects or environments. Being a platform based on a simple I/O board and an I.D.E, it's used to develop independant interactions, connected to computer software.
Our assignment was to burn a program onto the microprocessor and to make a LED blink on the circuit board.
The ardunio code is given below:

/*
This program makes an LED blink on the arduino board.
 */

int ledPin = 13;                // LED connected to digital pin 13

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()                     // run over and over again
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

Assignment 3: Button
The first of the interactions with Arduino was to transfer signal from computer to the chip through serial port.
The code is given below:

Arduino Code:

int outputPins[] = {3,4,13};
//int outputPin = 13;
int val;

void setup()
{
Serial.begin(9600);
pinMode(outputPins[0], OUTPUT);
pinMode(outputPins[1], OUTPUT);
pinMode(outputPins[2], OUTPUT);
}

void loop()
{
if (Serial.available()) {
val = Serial.read();
if (val == 'a') {
digitalWrite(outputPins[0], HIGH);
//delay(1000); 
}
if (val == 'b') {
digitalWrite(outputPins[1], HIGH);
//delay(1000); 
}
if (val == 'c') {
digitalWrite(outputPins[2], HIGH);
//delay(1000); 
}
if (val == 'e') {
digitalWrite(outputPins[0], LOW);
digitalWrite(outputPins[1], LOW);
digitalWrite(outputPins[2], LOW);
}
}
}

Processing Code:

import processing.serial.*;
Serial port;
void setup()
{
size(200, 200);
println(Serial.list());
// Open the port that the Arduino board is connected to (in this case #0)
// Make sure to open the port at the same speed Arduino is using (9600bps)
port = new Serial(this, Serial.list()[1], 9600);
}
int value =0;
void draw()
{
 fill(value);
 rect(50,50,50,50); 
}
void keyPressed() {
  if (key == 'a' || key == 'A') {
    value =255;
    port.write('a');
  }
  if (key == 'b' || key == 'B') {
    value= 200;
    port.write('b');
  }
  if (key == 'c' || key == 'C') {
    value=110;
    port.write('c');
  }
}
void keyReleased() {
  value=0;
  port.write('e');
}

Assignment 4: Photosensor
Arduino Code:

int potPin = 2; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);
}

void loop() {
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time

Serial.print(val);
}

Processing Code:

import processing.serial.*;

Serial port;

int Length = 200;
int Width = 300;

void setup()
{
  println(Serial.list());
  size (Width, Length);
  background(0,0,0);
  port = new Serial(this, Serial.list()[1], 9600);
//  frameRate(10);
}

int value =255;

void draw() {
  fill(255);
  rect(50, 50, 200, 100);

int val =  port.read();
println(" " + val + " ");
fill(val);
  rect(50, 50, 200, 100);
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License