Studio hhjjj workshop

Participation

위키 공동 편집을 원하시는 분은 다음 이메일로 자기소개를 부탁드립니다.
Send me an email to participate in workshop wiki.

songhojun@gmail.com

SensorComm Board

최근 사이트 활동

라이선스 안내

Creative Commons License
본 사이트의 모든 저작물크리에이티브 커먼즈 저작자표시-동일조건변경허락 2.0 대한민국 라이선스에 따라 이용할 수 있습니다.

arduino + processing code

//Arduino Code
 
 
 
//Arduino code
//ADC + Serial Communication

int reading;                // the readings from the analog input
int inputPin = 0;

void setup()
{
  Serial.begin(9600);                     // initialize serial communication with computer
 
}

void loop()
{
 
  reading = analogRead(inputPin); // read from the sensor
  Serial.println(reading);                // send it to the computer (as ASCII digits)
}
//Processing Code
 
 
 
// Example by Tom Igoe
import processing.serial.*;
int lf = 10;    // Linefeed in ASCII
//String myString = null;
Serial myPort;  // The serial port
int i;
void setup() {
  // List all the available serial ports
  println(Serial.list());
  size (800, 450);
  // I know that the first port in the serial list on my mac
  // is always my  Keyspan adaptor, so I open Serial.list()[0].
  // Open whatever port is the one you're using.
  myPort = new Serial(this, Serial.list()[0], 9600);
  myPort.clear();
  // Throw out the first reading, in case we started reading
  // in the middle of a string from the sender.
  //myString = myPort.readStringUntil(lf);
  //myString = null;
}
void draw() {
  background (255);
 
  while (myPort.available() > 0) {
    String myString;
    myString = myPort.readStringUntil(lf);
    if (myString != null) {
      i = int(trim(myString));
      println(i);
    }
  }
  ellipse (width/2, height/2, i, 100);
}