#include <SoftwareSerial.h>
#include "Keyboard.h"
SoftwareSerial HC12(8, 7); // RX on arduino connected to TX on HC12, TX on arduino connected to RX on HC12
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
Keyboard.begin();
HC12.begin(9600);
}
void loop() {
// use serial input to control the mouse:
if (HC12.available() > 0) {
Serial.println("got message");
char inChar = HC12.read();
switch (inChar) {
case 'x':
// move mouse up
//Mouse.move(0, -40);
Keyboard.write('x');
Serial.println("x");
break;
case 'c':
// move mouse down
//Mouse.move(0, 40);
Keyboard.write('c');
break;
case 'v':
// move mouse left
//Mouse.move(-40, 0);
Keyboard.write('v');
break;
}
}
}
Comments