Go Down

Topic: help me please!!! (Read 408 times) previous topic - next topic

parkjoohyung

Nov 22, 2007, 05:54 am Last Edit: Nov 22, 2007, 05:58 am by parkjoohyung Reason: 1
Thank you for Reading this post!
I'm sorry to say that i don't write Englich well.
Maybe, you don't understand my word.
sorry!

What should i do to link between arduino and processing?

////////////////////////<arduino>////////////////////////////////
int switchPin = 4;
void setup(){
 pinMode(switchPin, INPUT);
 Serial.begin(9600);
 }

void loop() {
 if(digitalRead(switchPin) == HIGH) {
   Serial.print(1,BYTE);
 }
 else {
   Serial.print(0,BYTE);
 }
 delay(100);
}
//////////////////////<processing>///////////////////////
import processing.serial.*;
Serial port;
int val;

void setup() {
 size(200,200);
 frameRate(10);
 port = new Serial(this, 9600);
}

void draw() {
 if(0 > port.available()) {
   val = port.read();
 }
 background(255);
 if (val == 0) {
   fill(0);
 }
 else {
   fill(204);
 }
 rect(50,50,100,100);
}

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

/////////////////////////////////////

This example is in the Processing Handbook from the MIT press.

when i code "blink" . It does work.
i think arduino and computer are related each other.

But arduino and processin aren't realated each other.

what should i do ?

Go Up