Processing Serial - FabLabSeoul/WingProject GitHub Wiki

Processing ํ”„๋กœ๊ทธ๋žจ์—์„œ Serial ์ •๋ณด๋ฅผ ํŒŒ์‹ฑํ•˜๋Š” ๋ถ€๋ถ„์„ ์ •๋ฆฌํ•œ๋‹ค.

์‹œ๋ฆฌ์–ผ๋กœ "Start,123,aaa,bbb,ccc,ddd" ํ˜•ํƒœ์˜ ์ •๋ณด๊ฐ€ ๋„˜์–ด์˜ฌ ๋•Œ, ํŒŒ์‹ฑํ•˜๋Š” ๋ฒ•.

int lf = 10;
String message = myPort.readStringUntil(lf); 
if (message != null)
{
    String [] data  = message.split(","); // ์ฝค๋งˆ(,) ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐ›์€ ๋ฐ์ดํ„ฐ๋ฅผ ์ž๋ฅธ๋‹ค. 
    if (data[0].equals("Start"))// ์ž๋ฅธ ๋ฐ์ดํ„ฐ์ค‘ ์ œ์ผ ์ฒ˜์Œ์ด Start์ผ ๊ฒฝ์šฐ
    {
        try {
            int n1 = Integer.parseInt(data[1]);
            String s1 = data[2];
        }
        catch(Throwable t) {
        }
    }
}

======================================================

์ฐธ์กฐ

http://kocoafab.cc/make/view/175