|
查看: 907|回复: 2
|
请问如何把Java接去serial port?
[复制链接]
|
|
|
本帖最后由 JX_Needle 于 16-3-2010 03:08 PM 编辑
我想写个program经过serial port来控制robot,但不懂要如何connect。
以下是我的code:
import java.awt.*;
import javax.comm.*;
public class ControlButtons extends java.applet.Applet
{
GridLayout myLayout = new GridLayout(3, 3);
Button button1 = new Button(" ");
Button buttonForward = new Button("Forward");
Button button2 = new Button(" ");
Button buttonLeft = new Button("Left");
Button buttonStop = new Button("Stop");
Button buttonRight = new Button("Right");
Button button3 = new Button(" ");
Button buttonReverse = new Button("Reverse");
Button button4 = new Button(" ");
public void init()
{
setLayout(myLayout);
add(button1);
button1.setVisible(false);
add(buttonForward);
add(button2);
button2.setVisible(false);
add(buttonLeft);
add(buttonStop);
add(buttonRight);
add(button3);
button3.setVisible(false);
add(buttonReverse);
add(button4);
button4.setVisible(false);
}
}
请问接下来该如何connect?得加什么command? 要用什么method?
谢谢各位的帮助及解答。 |
|
|
|
|
|
|
|
|
|
|
发表于 17-3-2010 10:07 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 17-3-2010 05:33 PM
|
显示全部楼层
你附上的code跟serial port完全無關...
MaokeJackson 发表于 17-3-2010 10:07 AM 
因为我不懂要如何接去serial port。 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|