------------------------------------------------------------------------------------------------
//http://arduino.cc/en/Reference/MouseKeyboard
#include <Keypad.h>
//HIDKeyboard Keyboard; // Initialize HIDKeyboard object
char shift = KEY_LEFT_SHIFT;
char ctrl = KEY_LEFT_CTRL;
char alt = KEY_LEFT_ALT;
char f2 = KEY_F2;
const int schemBoard = 2;
const byte ROWS = 4;
const byte COLS = 3;
char Keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {4, 9, 8, 6};
byte colPins[COLS] = {5, 3, 7};
Keypad customKeypad = Keypad( makeKeymap(Keys), rowPins, colPins, ROWS, COLS);
void setup() {
Keyboard.begin(); // Start communication
delay(2000); // Wait for device to be found as a Keyboard
}
void loop() {
char key = customKeypad.getKey();
if (key != NO_KEY){
if(schemBoard){ //schematic keys
if (key == '1'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('a');} //add
else if(key == '2'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('c');} //copy
else if(key == '3'){Keyboard.press(ctrl);Keyboard.press('d');} //delete
else if(key == '4'){Keyboard.press(ctrl);Keyboard.press('i');} //info
else if(key == '5'){Keyboard.press(ctrl);Keyboard.press('m');} //move
else if(key == '6'){Keyboard.press(alt);Keyboard.press('n');} //net
else if(key == '7'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('n');} //name
else if(key == '8'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('s');} //smash
else if(key == '9'){Keyboard.press(ctrl);Keyboard.press('t');} //text
else if(key == '0'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('v');} //value
else if(key == '*'){Keyboard.press(ctrl);Keyboard.press('w');} //wire
else if(key == '#'){Keyboard.press(alt);Keyboard.press(f2);} //window fit
}
else{ //board keys
if (key == '1'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('a');} //add
else if(key == '2'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('c');} //copy
else if(key == '3'){Keyboard.press(ctrl);Keyboard.press('d');} //delete
else if(key == '4'){Keyboard.press(ctrl);Keyboard.press('i');} //info
else if(key == '5'){Keyboard.press(ctrl);Keyboard.press('m');} //move
else if(key == '6'){Keyboard.press(alt);Keyboard.press('n');} //net
else if(key == '7'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('n');} //name
else if(key == '8'){Keyboard.press(ctrl);Keyboard.press('r');} //route
else if(key == '9'){Keyboard.press(ctrl);Keyboard.press('t');} //text
else if(key == '0'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('v');} //value
else if(key == '*'){Keyboard.press(shift);Keyboard.press(ctrl);Keyboard.press('r');} //ripup
else if(key == '#'){Keyboard.press(alt);Keyboard.press(f2);} //window fit
}
}
}
Very helpful blogging on PCB keypad. Already I’ve visited several links you provided in your list. All the links are very effective. I’d like to see more such beautiful links from you by this posting.
ReplyDelete