×

使用Arduino pro micro板的USB宏垫

消耗积分:0 | 格式:zip | 大小:0.14 MB | 2022-08-11

分享资料个

电路板图如下:
poYBAGL0ULuAFh3yAAGz21yHCxI645.png
pYYBAGL0UL6AG5gpAADi-BAl8Lc919.png

描述

USB 宏垫

使用 Arduino pro micro(或兼容)板的超级简单的 USB 宏垫。这使用了 16 个带有键帽的 Cherry MX 风格开关,键帽中有用于打印标签的空间。天空才是极限!

代码

代码

阿杜诺

  #include
  #include
   
  const byte nb_rows = 4; // four rows
  const byte nb_cols = 4; // four columns
  char key_chars[nb_rows][nb_cols] = {// The symbols of the keys
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
  };
  byte rowPins[nb_rows] = {9, 8, 7, 6}; // The pins where the rows are connected
  byte colPins[nb_cols] = {5, 4, 3, 2}; // The pins where the columns are connected
   
  SimpleKeypad kp1((char*)key_chars, rowPins, colPins, nb_rows, nb_cols); // New keypad called kp1
   
  void setup() {
  Serial.begin(9600);
  Serial.println("Press any key on the keypad and it will show up here :");
  }
   
  void loop() {
  char key = kp1.getKey();// The getKey function scans the keypad every 10 ms and returns a key only one time, when you start pressing it
  if (key) {// If getKey returned any key
  Serial.println(key);// it is printed on the serial monitor
  }
  if (key == 'D') {
  Keyboard.press(KEY_F13);
  Keyboard.releaseAll();
  }
  if (key == '#') {
  Keyboard.press(KEY_F14);
  Keyboard.releaseAll();
  }
  if (key == '0') {
  Keyboard.press(KEY_F15);
  Keyboard.releaseAll();
  }
  if (key == '*') {
  Keyboard.press(KEY_F16);
  Keyboard.releaseAll();
  }
  if (key == 'C') {
  Keyboard.press(KEY_F17);
  Keyboard.releaseAll();
  }
  if (key == '9') {
  Keyboard.press(KEY_F18);
  Keyboard.releaseAll();
  }
  if (key == '8') {
  Keyboard.press(KEY_F19);
  Keyboard.releaseAll();
  }
  if (key == '7') {
  Keyboard.press(KEY_F20);
  Keyboard.releaseAll();
  }
  if (key == 'B') {
  Keyboard.press(KEY_F21);
  Keyboard.releaseAll();
  }
  if (key == '6') {
  Keyboard.press(KEY_F22);
  Keyboard.releaseAll();
  }
  if (key == '5') {
  Keyboard.press(KEY_F23);
  Keyboard.releaseAll();
  }
  if (key == '4') {
  Keyboard.press(KEY_F24);
  Keyboard.releaseAll();
  }
  if (key == 'A') {
  Keyboard.press(KEY_LEFT_SHIFT);
  delay(250);
  Keyboard.press(KEY_F13);
  delay(250);
  Keyboard.release(KEY_F13);
  delay(250);
  Keyboard.release(KEY_LEFT_SHIFT);
  }
  if (key == '3') {
  Keyboard.press(KEY_LEFT_SHIFT);
  delay(250);
  Keyboard.press(KEY_F14);
  delay(250);
  Keyboard.release(KEY_F14);
  delay(250);
  Keyboard.release(KEY_LEFT_SHIFT);
  }
  if (key == '2') {
  Keyboard.press(KEY_LEFT_SHIFT);
  delay(250);
  Keyboard.press(KEY_F15);
  delay(250);
  Keyboard.release(KEY_F15);
  delay(250);
  Keyboard.release(KEY_LEFT_SHIFT);
  }
  if (key == '1') {
  Keyboard.press(KEY_LEFT_SHIFT);
  delay(250);
  Keyboard.press(KEY_F16);
  delay(250);
  Keyboard.release(KEY_F16);
  delay(250);
  Keyboard.release(KEY_LEFT_SHIFT);
  }
  }

CAD-定制零件和外壳

 

 

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !