Im thinking about using Arduino to build a 6 key keyboard as a prototype for an electronic Braille typewriter, the thing is that this keyboard doesnt work as usual, the user presses multiple keys at the same time to create a specific combination of dots, and only once the user let`s go of all the keys is that the letter is displayed.
Im currently using multiple push buttons conected to the same analog port, with different resistances connecting them in parallel so I can tell with ones are pressed depending on the value of the current. The buttons are connected in pairs so Im using 3 different analog ports, but I dont know if thats the best way to do that, and also I have no idea how to make an analong interrupt so that only when all push buttons are not pressed, it displays the letter.
I`m taking any suggestions, even if it means changing the whole system.
Under ideal circumstances, you could detect 1023 different buttons on one analog input. You just need to select the resistances properly so that you have identifiable levels to search for. If you have got it working on 3 inputs, then keep using that.
Have you read "Planning and Implementing an Arduino Program" over in the programming section? That will have some good ideas on how to set up your program.
Basically, I would make sure that my main loop is never 'blocked' waiting for a button or other event. That way it will run thousands of times per second, checking all of the inputs over and over and over. Then it waits for the correct combination of inputs. Think about what it will see if it is able to look at all buttons 1000 times per second. It will see the first button go down, maybe with some electrical bouncing, then 5 'steps' later it will see your second button and so on. Once it sees that there's been no changes in 0.1 seconds, then it can be confident that you don't have any more fingers pressing any more buttons. Output this immediately, or memorise it and wait until all the buttons have been released, according to your specification.
I would use 6 digital input pins (wire buttons between pins and Ground).
const int dots = 6;
const in buttons[dots] = {2,3,4,5,6,7};
void setup() {
for (int i=0; i<dots; i++) {
pinMode(buttons[i], INPUT_PULLUP); // Active LOW
}
}
void loop() {
static unsigned char pressed = 0;
int buttonsDown = 0;
for (int i=0; i<dots; i++) {
if (digitalRead(buttons[i]) == LOW) {
pressed |= (1<<i); // Set a bit to remember the button being down
buttonsDown++;
}
}
if (buttonsDown == 0 && pressed != 0) {
// pressed contains the index of the character to display
// Process that input here
pressed = 0; // Reset for more input
}
}
Ramploy:
Im thinking about using Arduino to build a 6 key keyboard as a prototype for an electronic Braille typewriter, the thing is that this keyboard doesnt work as usual, the user presses multiple keys at the same time to create a specific combination of dots, and only once the user let`s go of all the keys is that the letter is displayed.
I'd also create the logic with digital buttons.
The maximum number buttons pressed at the same time define the Braille key.
So while the number of pressed buttons increases, remember the key accordingly.
And after all buttons are released, the remembered key is printed / sent to output.