Arcade Cabinet for Tablets: Difference between revisions

From air
Jump to navigation Jump to search
 
Line 25: Line 25:
===[[Arduino]] sketch===
===[[Arduino]] sketch===
<pre>
<pre>



const int NBANABUT = 4;
const int NBANABUT = 4;
const int aButton[NBANABUT] = {A2, A3, A4, A5};
const int aButton[NBANABUT] = {A2, A3, A4, A5};
//const int aChar[NBANABUT] = {'1', '2', '3', '4' };
const int aChar[NBANABUT] = {'W', 'D', 'A', 'S' };
// warning, qwerty keyboard
const int aChar[NBANABUT] = {KEY_UP_ARROW, KEY_RIGHT_ARROW, KEY_DOWN_ARROW, KEY_LEFT_ARROW};
// W here gives Z on azerty Keyboard
//const int aChar[NBANABUT] = {KEY_UP_ARROW, KEY_RIGHT_ARROW, KEY_DOWN_ARROW, KEY_LEFT_ARROW};
int aFlag[NBANABUT] = {false, false, false, false };
int aFlag[NBANABUT] = {false, false, false, false };


Line 35: Line 38:
const int dButton[8] = {2, 3, 4, 5, 6, 7, 8, 9};
const int dButton[8] = {2, 3, 4, 5, 6, 7, 8, 9};
//const int dChar[8] = {'A', 'B', 'C', 'D', 'E','F','G','H' };
//const int dChar[8] = {'A', 'B', 'C', 'D', 'E','F','G','H' };
// order of button from left to right, line by line
const int dChar[8] = {KEY_RETURN, 'B', 'C', 'D', 'E','F','G','H' };
const int dChar[8] = {'d','h','g','c','f','b','e','q'};
int dFlag[8] = {false, false, false, false, false, false, false, false };
int dFlag[8] = {false, false, false, false, false, false, false, false };

void setup() {

void setup(){
for(int d=0;d<NBDIGBUT;d++) pinMode(dButton[d], INPUT_PULLUP);
for(int d=0;d<NBDIGBUT;d++) pinMode(dButton[d], INPUT_PULLUP);
Keyboard.begin();
Keyboard.begin();
}
}


void loop() {
void loop(){

for(int d=0;d<NBDIGBUT;d++) {
for(int d=0;d<NBDIGBUT;d++) {
if (!dFlag[d] && digitalRead(dButton[d]) == HIGH) {
if (!dFlag[d] && digitalRead(dButton[d]) == HIGH) {

Keyboard.press(dChar[d]);
dFlag[d]=true;
dFlag[d]=true;

} else
}else
if (dFlag[d] && digitalRead(dButton[d]) == LOW) {
if (dFlag[d] && digitalRead(dButton[d]) == LOW) {
Keyboard.press(dChar[d]);
Keyboard.press(dChar[d]);
delay(10); // to avoid multiple press
Keyboard.releaseAll();
dFlag[d]=false;
dFlag[d]=false;
}
}
}
}
for(int a=0;a<NBANABUT;a++) {
for(int a=0;a<NBANABUT;a++) {
if (!aFlag[a] && analogRead(aButton[a]) > 1024/2) {
if (!aFlag[a] && analogRead(aButton[a]) > 1024/2) {
aFlag[a]=true;
aFlag[a]=true;
Keyboard.release(aChar[a]);
Keyboard.release(aChar[a]);
delay(10); // to avoid multiple press
} else
} else
if (aFlag[a] && analogRead(aButton[a]) < 1024/2) {
if (aFlag[a] && analogRead(aButton[a]) < 1024/2) {
Keyboard.press(aChar[a]);
Keyboard.press(aChar[a]);
aFlag[a]=false;
aFlag[a]=false;
delay(10); // to avoid multiple press
}
}
}
}
}
}
</pre>
</pre>

Latest revision as of 13:40, 14 February 2014

ArcadeCabinetTablet5.jpg

The goal of this project is to provide arcade-style cabinet for 11-inch tablets.

Hardware

Extra

Design

Software

Arduino sketch



const int NBANABUT = 4;
const int aButton[NBANABUT] = {A2, A3, A4, A5};
const int aChar[NBANABUT] = {'W', 'D', 'A', 'S' }; 
// warning, qwerty keyboard
// W here gives Z on azerty Keyboard
//const int aChar[NBANABUT] = {KEY_UP_ARROW, KEY_RIGHT_ARROW, KEY_DOWN_ARROW, KEY_LEFT_ARROW};
int aFlag[NBANABUT] = {false, false, false, false };

const int NBDIGBUT = 8;
const int dButton[8] = {2, 3, 4, 5, 6, 7, 8, 9};
//const int dChar[8] = {'A', 'B', 'C', 'D', 'E','F','G','H' };
// order of button from left to right, line by line
const int dChar[8] = {'d','h','g','c','f','b','e','q'};
int dFlag[8] = {false, false, false, false, false, false, false, false };
        


void setup(){
  for(int d=0;d<NBDIGBUT;d++) pinMode(dButton[d], INPUT_PULLUP);
  Keyboard.begin();
}

void loop(){

  
   for(int d=0;d<NBDIGBUT;d++) {
    if (!dFlag[d] && digitalRead(dButton[d]) == HIGH) {

      dFlag[d]=true;

    }else 
    if (dFlag[d] && digitalRead(dButton[d]) == LOW) {
      Keyboard.press(dChar[d]);
      delay(10); // to avoid multiple press
      Keyboard.releaseAll();
      dFlag[d]=false;
    }
  }
  
  
  
for(int a=0;a<NBANABUT;a++) {
    if (!aFlag[a] && analogRead(aButton[a]) > 1024/2) {
      aFlag[a]=true;
      Keyboard.release(aChar[a]);
      delay(10); // to avoid multiple press
    } else
    if (aFlag[a] && analogRead(aButton[a]) < 1024/2) {
      Keyboard.press(aChar[a]);
      aFlag[a]=false;
      delay(10); // to avoid multiple press
    }
  }
  
}

Processing sketches

Javascript et HTML

Gallerie

ArcadeCabinetTablet.png ArcadeCabinetTablet1.jpg ArcadeCabinetTablet2.jpg ArcadeCabinetTablet3.jpg ArcadeCabinetTablet4.jpg ArcadeCabinetTablet5.jpg