processingとarduinoの連携

12
Processing Arduino

Upload: jun-ichi-shinde

Post on 19-Jan-2015

1.737 views

Category:

Technology


2 download

DESCRIPTION

福井情報技術者協会(FITEA)主催のArduino入門で発表したハンズオン用のスライドです。 http://fitea.org/?p=110 http://blog.shos.info/archives/2009/09/fiteaard

TRANSCRIPT

Page 1: ProcessingとArduinoの連携

Processing Arduino

Page 2: ProcessingとArduinoの連携

Processing

• C/Java

• 3D/ /AR

• Arduino IDE

• Serial Arduino

Page 3: ProcessingとArduinoの連携
Page 4: ProcessingとArduinoの連携

• Download Processing 1.0http://processing.org/download

• Processing 1.0.6

•Mac Applications D&D

Page 5: ProcessingとArduinoの連携

Processing

void setup(){size( 255, 255 ); //

}

void draw() { //background( 255 ); //noStroke(); //color cl = color( 255, 255, 0, 127 ); // R,G,B,αfill( cl ); //ellipse( 100, 100, 50, 50 ); // ( x, y, w, h );

}

Page 6: ProcessingとArduinoの連携

Arduino

• Arduino

– シリアルポートに可変抵抗の値をバイト値で送信

– port.print( val, BYTE );

• Processing

– シリアルポートからバイト値を受信

– int val = port.read();

Page 7: ProcessingとArduinoの連携

Arduino

int val = 0;

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

}

void loop(){val = analogRead( 0 ) / 4; // 4 1byteSerial.print( val, BYTE ); //delay( 50 ); //

}

Page 8: ProcessingとArduinoの連携

Processing

import processing.serial.*;Serial port;int val = 0; // void setup(){

size( 255, 255 ); // port = new Serial( this, "COM4", 9600 );

}void draw(){

background( 255 );ellipse( 100, 100, val, val );

}void serialEvent( Serial p ) {

val = port.read();}

Page 9: ProcessingとArduinoの連携

Processing

• 2008: Processing

– http://kousaku-kousaku.blogspot.com/2008/07/processing_10.html

• Processing

– http://yoppa.jpn.org/presen.php?itemid=169

• yasushi noguchi class » Processing

– http://r-dimension.xsrv.jp/classes_j/processing/

Page 10: ProcessingとArduinoの連携

C#(.NET)

• SerialPort

–浅草ギ研 Visual C# 2005 のシリアル通信機能を使ってみるhttp://www.robotsfx.com/robot/robohow/RoboHow60/RoboHow60.html

Page 11: ProcessingとArduinoの連携

C#(.NET)

• SerialPort Form

• BaudRate 9600

• PortName ”COM4”

• Form serialPort1.Open()

• Form serialPort1.Close()

• DataReceived ReadByte

• Write

– var byteArray = new byte[] = { 1, 2, 3, 4, 5 };

– serialPort1.Write( byteArray, 0, 5 ); // 配列の0番から5個送信

Page 12: ProcessingとArduinoの連携

Flash/AIR

• Funnel

• Flash(AIR)TECH Matari

– http://tech.ironhearts.com/blog/archives/39