Rédation en cours ….
Pour des besoins personnels, j’ai eut envie de me créer un petit clavier avec uniquement les touches de fonctions importantes de Sketchup.
Mon choix va donc naturellement se porter vers une carte a base d’Atmega32u4, Arduino leornado, Arduino micro, ou une copie chinoise de préférence de petite taille …
Le clavier 4×4 de Robotdyn as le bon goût de ne nécessiter que 3 fils de connexion !
Une masse, un +5V, et une broche analogique, dans mon cas la N° 3.
Shéma en PDF: Mod-ButtonKeypad4x4
Besoins matériel:
Button Keypad 4×4 module https://robotdyn.com/button-keypad-4×4-module.html
Micro ATmega32U4-MU https://robotdyn.com/micro-atmega32u4-mu.html
Ou
ATMega32U4 BS PMicro Pro Micro Leonardo Arduino Compatible Development Board Lien Banggood
Code Arduino:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
// Clavier // https://robotdyn.com/catalogsearch/result/?q=Keypad // Buttons Out Level for VCC=5V (0~1023) // https://www.arduino.cc/reference/en/language/functions/usb/keyboard/ // https://www.arduino.cc/reference/en/language/functions/usb/mouse/ // https://td72pro.com/tutoriel-envoyer-des-touches-de-clavier-avec-un-arduino/ //DIY IMU-based SmartTV controller/mouse with Arduino Micro // https://www.hackster.io/movsensllc/diy-imu-based-smarttv-controller-mouse-with-arduino-micro-548353 // https://www.arduino.cc/en/Reference/KeyboardModifiers // Librairie Keyboard (utilisation, explication et conversion AZERTY) // https://forum.arduino.cc/index.php?topic=552465.0 // KeyboardAzertyFr // https://github.com/martin-leo/KeyboardAzertyFr // Custom Mouse Wheel As PocketNC Jog Wheel // https://www.allwinedesigns.com/blog/pocketnc-jog-wheel /* 1~1023 2~930 3~850 4~790 5~680 6~640 7~600 8~570 9~512 10~487 11~465 12~445 13~410 14~330 15~277 16~238 */ /* https://www.w3.org/2002/09/tests/keys.html Envoyer keycode + 136 220 '\334' Keypad / 221 '\335' Keypad * 222 '\336' Keypad - 223 '\337' Keypad + 224 '\340' Keypad ENTER 225 '\341' Keypad 1 and End 226 '\342' Keypad 2 and Down Arrow 227 '\343' Keypad 3 and PageDn 228 '\344' Keypad 4 and Left Arrow 229 '\345' Keypad 5 230 '\346' Keypad 6 and Right Arrow 231 '\347' Keypad 7 and Home 232 '\350' Keypad 8 and Up Arrow 233 '\351' Keypad 9 and PageUp 234 '\352' Keypad 0 and Insert 235 '\353' Keypad . and Delete */ /* The Leonardo's definitions for modifier keys are listed below: Key Hexadecimal value Decimal value KEY_LEFT_CTRL 0x80 128 KEY_LEFT_SHIFT 0x81 129 KEY_LEFT_ALT 0x82 130 KEY_LEFT_GUI 0x83 131 KEY_RIGHT_CTRL 0x84 132 KEY_RIGHT_SHIFT 0x85 133 KEY_RIGHT_ALT 0x86 134 KEY_RIGHT_GUI 0x87 135 KEY_UP_ARROW 0xDA 218 KEY_DOWN_ARROW 0xD9 217 KEY_LEFT_ARROW 0xD8 216 KEY_RIGHT_ARROW 0xD7 215 KEY_BACKSPACE 0xB2 178 KEY_TAB 0xB3 179 KEY_RETURN 0xB0 176 KEY_ESC 0xB1 177 KEY_INSERT 0xD1 209 KEY_DELETE 0xD4 212 KEY_PAGE_UP 0xD3 211 KEY_PAGE_DOWN 0xD6 214 KEY_HOME 0xD2 210 KEY_END 0xD5 213 KEY_CAPS_LOCK 0xC1 193 KEY_F1 0xC2 194 KEY_F2 0xC3 195 KEY_F3 0xC4 196 KEY_F4 0xC5 197 KEY_F5 0xC6 198 KEY_F6 0xC7 199 KEY_F7 0xC8 200 KEY_F8 0xC9 201 KEY_F9 0xCA 202 KEY_F10 0xCB 203 KEY_F11 0xCC 204 KEY_F12 0xCD 205 */ #include <Keyboard.h> int analogPin = A3; int timeout; // variable de délai d'attente utilisée dans la boucle int keypadStatus; // Utilisé pour contrôler les boutons sur lesquels vous appuyez. int btnum; void setup() { Serial.begin(9600); // setup serial Keyboard.begin(); // initialiser le contrôle sur le clavier } void loop() { timeout = 1000; // délai de répétition keypadStatus = getKeypadStatus(); // savoir quels boutons sont enfoncés //Serial.println(keypadStatus); //Serial.println(getKeypadStatus()); //Serial.println(analogRead(analogPin)); if (keypadStatus >= 1) // Si un bouton est enfoncé allez ici { btNum(keypadStatus); while ((getKeypadStatus() == keypadStatus) && (--timeout)) // Decrementer le timeout et vérifiez si la touche est maintenue enfoncée delayMicroseconds(timeout); while (getKeypadStatus() == keypadStatus) // On répète la même touche après le temps d'attente tant que la touche ne change pas { btNum(keypadStatus); delay(50); } } //Fin if Keyboard.releaseAll(); } // End-loop //------------------------------------------------------ int getKeypadStatus() { int keypadStatus = analogRead(analogPin); // read the input pin if (keypadStatus >= 0 && keypadStatus <= 219) keypadStatus=0; else if (keypadStatus >= 220 && keypadStatus <= 250) keypadStatus=16; else if (keypadStatus >= 251 && keypadStatus <= 280) keypadStatus=15; else if (keypadStatus >= 281 && keypadStatus <= 350) keypadStatus=14; else if (keypadStatus >= 351 && keypadStatus <= 420) keypadStatus=13; else if (keypadStatus >= 421 && keypadStatus <= 455) keypadStatus=12; else if (keypadStatus >= 456 && keypadStatus <= 475) keypadStatus=11; else if (keypadStatus >= 476 && keypadStatus <= 495) keypadStatus=10; else if (keypadStatus >= 496 && keypadStatus <= 520) keypadStatus=9; else if (keypadStatus >= 521 && keypadStatus <= 580) keypadStatus=8; else if (keypadStatus >= 581 && keypadStatus <= 620) keypadStatus=7; else if (keypadStatus >= 621 && keypadStatus <= 645) keypadStatus=6; else if (keypadStatus >= 646 && keypadStatus <= 685) keypadStatus=5; else if (keypadStatus >= 686 && keypadStatus <= 795) keypadStatus=4; else if (keypadStatus >= 796 && keypadStatus <= 860) keypadStatus=3; else if (keypadStatus >= 861 && keypadStatus <= 940) keypadStatus=2; else if (keypadStatus >= 941 && keypadStatus <= 1023) keypadStatus=1; return keypadStatus; } void btNum(int Numbt) { if (Numbt == 1){ //Keyboard.press(89+136); //affiche 1 Keyboard.press('p'); } else if (Numbt == 2){ //Keyboard.press(90+136); //affiche 2 Keyboard.press(59);//m en querty ASCII ! https://ascii.cl/ } else if (Numbt == 3){ //Keyboard.press(91+136); //affiche 3 Keyboard.press('s'); } else if (Numbt == 4){ //Keyboard.press(92+136); //affiche 4 Keyboard.press(0x20); // Space is decimal 32, or 0x20 in Hexadecimal. } else if (Numbt == 5){ //Keyboard.press(93+136); //affiche 5 Keyboard.press('o'); } else if (Numbt == 6){ //Keyboard.press(94+136); //affiche 6 Keyboard.press('f'); } else if (Numbt == 7){ //Keyboard.press(95+136); //affiche 7 Keyboard.press('a'); } else if (Numbt == 8){ //Keyboard.press(96+136); //affiche 8 Keyboard.press('h'); } else if (Numbt == 9){ //Keyboard.press(97+136); //affiche 9 Keyboard.press('t'); } else if (Numbt == 10){ //Keyboard.press(89+136); //affiche 1 //Keyboard.press(98+136); //affiche 0 Keyboard.press('q'); } else if (Numbt == 11){ //Keyboard.press(89+136); //affiche 1 //Keyboard.release(89+136);//relacher la touche pour doubler le 1 //Keyboard.press(89+136); //affiche 1 Keyboard.press('r'); } else if (Numbt == 12){ //Keyboard.press(89+136); //affiche 1 //Keyboard.press(90+136); //affiche 2 Keyboard.press('w'); } else if (Numbt == 13){ //Keyboard.press(89+136); //affiche 1 //Keyboard.press(91+136); //affiche 3 Keyboard.press('e'); } else if (Numbt == 14){ //Keyboard.press(89+136); //affiche 1 //Keyboard.press(92+136); //affiche 4 Keyboard.press('c'); } else if (Numbt == 15){ //Keyboard.press(89+136); //affiche 1 //Keyboard.press(93+136); //affiche 5 Keyboard.press('l'); } else if (Numbt == 16){ //Keyboard.press(89+136); //affiche 1 //Keyboard.press(94+136); //affiche 6 Keyboard.press('b'); } } |
Un exemple de raccourcis pour Sketchup:
Câblage, 3 fils a connecter !

Ca fonctionne parfaitement 🙂
IL me reste a imprimer en 3D une joli BoiBoite !