Skip to content

Instantly share code, notes, and snippets.

@chepecarlos
Forked from joksan/Alfombra_Pro_Micro.ino
Created September 2, 2012 23:25
Show Gist options
  • Save chepecarlos/3605582 to your computer and use it in GitHub Desktop.
Save chepecarlos/3605582 to your computer and use it in GitHub Desktop.
Codigo para la alfombra de baile de Grupo Linux
int mapa_botones[9] = { 5, 6, 7, 8, 9, 10, 11, 12, 13 };
int BotonesAnt[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
int BotonesAct[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
void setup() {
int i;
for (i=0; i<9; i++) {
digitalWrite(mapa_botones[i], HIGH);
pinMode(mapa_botones[i], INPUT);
}
Keyboard.begin();
}
void loop() {
int i;
//Guarda el estado anterior de los botones y los refresca
for (i=0; i<9; i++) {
BotonesAnt[i] = BotonesAct[i];
BotonesAct[i] = digitalRead(mapa_botones[i]);
}
//Determina las transiciones en los botones
for (i=0; i<9; i++) {
if (!BotonesAnt[i] && BotonesAct[i]) {
Keyboard.release('a' + i);
}
if (BotonesAnt[i] && !BotonesAct[i]) {
Keyboard.press('a' + i);
}
}
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment