I m using my Arduino Leo to convert an old SINCLAIR SPECTRUM computer into a USB keyboard for a Raspberry PI
Similar to this one
I followed the tutorial above and had some success and I can now use the Spectrum as a VERY basic keyboard
BUT Currently I can t access any COMMAS FULL STOPS PUNCTUATION ETC
These are normally accessed by using the Spectrum SYMBOL SHIFT key as a modifier
I d like to create an exact clone of the original Spectrum keyboard along with all of the characters and modifiers and auto repeat
So my fist question IS THIS POSSIBLE
Second HOW DO I DO IT
Below is the code from the tutorial I followed If you gentlemen could show me how to tweak it for my needs then I d be very grateful INSERT SMILEYFACE
///////////// MATRIX CONFIGURATION /////////////
////////////////////////////////////////////////
const int dataNo = 5;
const int addressNo = 8;
int dataPin[dataNo] = {A0,A1,A2,A3,A4};
int data[dataNo] = {0,1,2,3,4};
int address[addressNo] = {2,3,4,5,6,7,8,9};
char keyMap[dataNo][addressNo][2] =
{// 2 3 4 5 6 7 8 9 << address lines
{{'b','B'},{'h','H'},{'v','V'},{'y','Y'},{'6','6'},{'g','G'},{'t','T'},{'5','5'}}, // A0
{{'n','N'},{'j','J'},{'c','C'},{'u','U'},{'7','7'},{'f','F'},{'r','R'},{'4','4'}}, // A1
{{'m','M'},{'k','K'},{'x','X'},{'i','I'},{'8','8'},{'d','D'},{'e','E'},{'3','3'}}, // A2
{{' ',' '},{'l','L'},{'z','Z'},{'o','O'},{'9','9'},{'s','S'},{'w','W'},{'2','2'}}, // A3
{{' ',' '},{' ',' '},{' ',' '},{'p','P'},{'0','0'},{'a','A'},{'q','Q'},{'1','1'}} // A4
};
boolean wasReleased = true;
int reRelease = 0;
int capital = 0;
////////////// KEYBOARD INTERFACE //////////////
////////////////////////////////////////////////
void setup()
{
// set the address lines to outputmode and prep (high)
for (int a=0; a<addressNo; a++)
{
pinMode(address[a], OUTPUT);
digitalWrite(address[a], HIGH);
}
// set the data lines to input
for(int d=0; d<dataNo; d++)
{
pinMode(dataPin[d], INPUT);
}
// intialise keyboard connection
Keyboard.begin();
}// end of setup
void loop()
{
// cycle the address lines to low for scanning, then reset
for (int aCyc=0; aCyc<addressNo; aCyc++)
{
digitalWrite(address[aCyc], LOW);
// scan each of the data lines for drop
for(int tData=0; tData<dataNo; tData++)
{
int pressed = digitalRead(dataPin[tData]);
if(pressed == 0) //a low voltage is detected
{
// only go thorugh with registering a button press if nothing was pressed before
// i.e. only one keystroke while a button is held down - stops 'nnnnnnnnnnnnnnn'
if (wasReleased == true)
{
// change the caps lock or output the keystroke
if((aCyc == 2) && (tData == 4)) capital++;
else if((aCyc == 0) && (tData == 3)) Keyboard.write(KEY_BACKSPACE);
else if((aCyc == 1) && (tData == 4)) Keyboard.write(KEY_RETURN);
else Keyboard.print(keyMap[tData][aCyc][capital]);
}
// end the keystroke
Keyboard.releaseAll();
// toggle caps-lock off if second press
if(capital > 1) capital = 0;
// lock the loop out of sending more keystrokes to USB until the key is released
wasReleased = false;
reRelease = 0;
}
reRelease++;
}
digitalWrite(address[aCyc], HIGH);
}
// reset to allow typing if no buttons pressed
// (if reRelease gets all the way through the matrix without resetting)
if (reRelease > (dataNo*addressNo))
{
wasReleased = true;
}
}
Thank You