Guest User

Untitled

a guest
Dec 11th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. int mapa_botones[9] = { 5, 6, 7, 8, 9, 10, 16, 14, 15 };
  2. int BotonesAnt[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  3. int BotonesAct[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  4.  
  5. void setup() {
  6. int i;
  7.  
  8. for (i=0; i<9; i++) {
  9. digitalWrite(mapa_botones[i], HIGH);
  10. pinMode(mapa_botones[i], INPUT);
  11. }
  12.  
  13. Keyboard.begin();
  14. }
  15.  
  16. void loop() {
  17. int i;
  18.  
  19. //Guarda el estado anterior de los botones y los refresca
  20. for (i=0; i<9; i++) {
  21. BotonesAnt[i] = BotonesAct[i];
  22. BotonesAct[i] = digitalRead(mapa_botones[i]);
  23. }
  24.  
  25. //Determina las transiciones en los botones
  26. for (i=0; i<9; i++) {
  27. if (!BotonesAnt[i] && BotonesAct[i]) {
  28. Keyboard.release('a' + i);
  29. }
  30.  
  31. if (BotonesAnt[i] && !BotonesAct[i]) {
  32. Keyboard.press('a' + i);
  33. }
  34. }
  35.  
  36. delay(10);
  37. }
Add Comment
Please, Sign In to add comment