Devices & Components
Arduino Leonardo with Headers
RobotDyn 4x4 module
Male/Female Jumper Wires
Hardware & Tools
3D Printer (generic)
Software & Tools
Arduino IDE
Project description
Code
Macro Keypad
arduino
Its a macro keypad. you can use it to open a program, help with video editing, streaming or simply just copy and paste.
1//Gytis_Orz sketch from Hackster.io more info https://www.hackster.io/Gytis_Orz/macro-keypad-02cb43 2// Wiring: 3// VCC -> 5V 4// GND -> GND 5// OUT -> A1 (Analog 1) 6#include<Keyboard.h> 7#define KEY_MENU 0xED 8void setup() { 9 Serial.begin(9600); 10} 11 12void loop() { 13 // is any button pressed? 14 int valueA1=get_button(); 15 if(valueA1>0) { 16 Serial.print("Click button "); 17 Serial.println(valueA1); 18 delay(500); 19 } 20} 21 22// button detection 23int get_button() { 24 // get A1 analog input value 25 int val=analogRead(A1); 26 if(val>1000) 27 return 1; //you can change the "return x;" to whatever you want like using a keyboard library you can make it to copy or paste something 28 else if(val>900) 29 return 2; 30 else if(val>820) 31 return 3; 32 else if(val>750) 33 return 4; 34 else if(val>660) 35 return 5; 36 else if(val>620) 37 return 6; 38 else if(val>585) 39 return 7; 40 else if(val>540) 41 return 8; 42 else if(val>500) 43 return 9; 44 else if(val>475) 45 return 10; 46 else if(val>455) 47 return 11; 48 else if(val>425) 49 return 12; 50 else if(val>370) 51 return 13; 52 else if(val>300) 53 return 14; 54 else if(val>260) 55 return 15; 56 else if(val>200) 57 return 16; 58 else 59 return 0; 60}
Comments
Only logged in users can leave comments