Fab Academy 2015, Dong-Hyun Kim

Interface & application programming

Processing

This is my first time using ‘Processing’, So I study about ‘how to using processing with arduino.’

You can learn ‘processing’ in Sparkfun web page.


I just practice how to draw something in processing.

void setup(){
size(400,400);
stroke(255);

}

void draw(){
background(192,64,0);
line(0,0,mouseX,mouseY);
}

In the past assignment ‘Input devices’, I controlled flex sensor, For this week assignment, I tried to use flex sensor either.

When I bend a flex sensor, Arduino measure how much bend a flex sensor and send data to computer, and ‘processing’ shows me animation.

In that animation when do I bend a flex sensor, the man goes up.

Arduino Code

void setup()
{
Serial.begin(9600);
}

void loop()
{
Serial.println(analogRead(A5));
delay(100);
}

Processing Code

import processing.serial.*;

Serial myPort;
float y

void setup(){
size(400,400);
delay(3000);
myPort=new Serial(this, "COM3", 9600);
}

void draw(){
float y = arduino.analogRead(0);
y = constrain(y, 0, 250);
y = map(y, 0, 250, 0, 350);
background(255);
fill(125);
noStroke();
rect(0, height-50, width, height);
drawMan(y);
delay(100);
}

void drawMan(float y){
fill(255);
stroke(0);
ellipse(width/2, y, 30, 30);
line(width/2-45, y+15, width/2+45,y+15);
line(width/2, y+15, width/2, y+50);
line(width/2, y+50, width/2-20, y+95);
line(width/2, y+50, width/2+20, y+95);
}

Problem

   
When I did uploading ‘Firmata’ to Arduino, It signed to me ‘ avrdude: stk500_recv(): programmer is not responding.’ So, I did googling for trouble shooting.

There are 2 reasons why It did’t upload on arduino.

  1. Clock difference
  2. USB cable problem

 

When I change cable, there are no reaction.
So, I tried to change clock in firmata source code. But also that is not solution.

The problem is the selection of ATmega processor. I choose ATmega328.

Then uploading was fine.

Download Files

Arduino and Processing code

Makers Gonna Make !