Advertisement
gabbyshimoni

ProMICROwHC12RX keyboard

Feb 12th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. #include "Keyboard.h"
  3.  
  4. SoftwareSerial HC12(8, 7); // RX on arduino connected to TX on HC12, TX on arduino connected to RX on HC12
  5.  
  6. void setup() {
  7.   // Open serial communications and wait for port to open:
  8.   Serial.begin(9600);
  9.   Keyboard.begin();
  10.   HC12.begin(9600);
  11.   }
  12.  
  13. void loop() {
  14.   // use serial input to control the mouse:
  15.   if (HC12.available() > 0) {
  16.     Serial.println("got message");
  17.     char inChar = HC12.read();
  18.  
  19.     switch (inChar) {
  20.       case 'x':
  21.         // move mouse up
  22.         //Mouse.move(0, -40);
  23.         Keyboard.write('x');
  24.         Serial.println("x");
  25.         break;
  26.       case 'c':
  27.         // move mouse down
  28.         //Mouse.move(0, 40);
  29.         Keyboard.write('c');
  30.         break;
  31.       case 'v':
  32.         // move mouse left
  33.         //Mouse.move(-40, 0);
  34.         Keyboard.write('v');
  35.         break;
  36.     }
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement