HalfaGeek

The following code describes how processing to arduino serial communication can be done…processing to arduino communication is very helpful when kinect is used along with processing..

Processing code

import processing.serial.*;
Serial port;

void setup() {
size(256, 150);

println("Available serial ports:");
println(Serial.list());

port = new Serial(this, Serial.list()[0], 9600);

}

void draw() {
// draw a gradient from black to white
for (int i = 0; i < 256; i++) {
stroke(i);
line(i, 0, i, 150);
}

// write the current X-position of the mouse to the serial port as
// a single byte
port.write(mouseX);
}

Serial.list()[0] uses the first port in this list (number 0) and aud used is 9600 if you know the port you can give it directly..

Arduino code

const int ledPin = 12; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); } void loop() { byte brightness; if (Serial.available()) { brightness = Serial.read(); if(brightness > 100){ digitalWrite(ledPin,HIGH); } else{…

View original post 47 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s