|
|
听说芯片是32u4的板子可以模拟鼠标键盘的动作,现有一下位机,是一个监控器的控制板,能够插USB鼠标和显示器的,插上后能直接识别鼠标。
于是想是否能够利用leonardo的板子模拟鼠标这一动作,这样它就可以自行运动了,不用我每次都去操作。
现在能够实现PC1---> USB转TTL PL2303HX模块--->板子--->PC2,
当PC1通过串口工具,发送字符可以控制PC2的鼠标的动作,代码入校
- void setup()
- {
- Serial.begin(9600); //This pipes to the serial monitor
- Serial1.begin(9600); //This is the UART, pipes to sensors attached to board
- while (!Serial) {
- ; // wait for serial port to connect. Needed for Leonardo only
- }
- }
- void loop()
- {
- int inByte = Serial1.read();
- switch (inByte) {
- case 'l':
- Serial.println("Go Left");
- Mouse.move(10,0,0);
- break;
- case 'r':
- Serial.println("Go Right");
- Mouse.move(-10,0,0);
- break;
- case 'u':
- Serial.println("Up");
- Mouse.move(0,-10,0);
- break;
- case 'd':
- Serial.println("Down");
- Mouse.move(0,10,0);
- break;
- case 'c':
- Serial.println("c");
- Mouse.press(MOUSE_LEFT);
- Mouse.release(MOUSE_LEFT);
- break;
- case 'x':
- Serial.println("x");
- Mouse.press(MOUSE_RIGHT);
- Mouse.release(MOUSE_RIGHT);
- break;
- default:
- Serial.println("none");
- Serial1.println("please send sm");
- delay(1000);
- }
- }
复制代码 现在我想实现,在PC端通过串口工具向板子发命令,使得下位机上的鼠标能够有相应的动作,不知道怎么做?
(下位机不是windows系统,是不能装什么驱动的,我想知道怎么让下位机认为板子是个鼠标?)
|
|