Such Hilfe bei der Programmierung einer USB Tastatur für Behinderte

Hallo

bin ganz neu hier und suche wie viele Hilfe bei einem Projekt für meinen behinderten Neffen. Er ist körperlich behindert und kann nicht sprechen aber er kann mit dem Daumen eine Tastatur bedienen aber nur sehr langsam.
Ich will ihm eine Tastatur ( USB ) mit einen kleinen Display bauen auf dem einfach nur die Zahlen Buchstaben angezeit werden die er nacheinander getipp hat .So könnte man mit Ihm kommuniziern .

ich habe einen Nano hier schon liegenund ein Display bei Youtube gibt es auch einen Beitrag der das genau so macht ( Doktor Volt) ich habe auch so alles aufgebaut der Couser blinkt aber ich bekomme keine Daten von der Tastatur ( denke ich zumindest ) habe so gut wie eine ahnung von dem Arduino .

Wie kann ich testen ob ich daten empfang von der Tastatur sollte doch im Serial Monitor angezeigt werden oder .

Vielleicht könnte mir da jemand weiter helfen oder hat einen ganz anderen Ansatz ich hätte auch noch einen Mega mit einen 4 x 20 Display der läuft bzw da kann ich text darstellen aber ich weis nicht wie da das Programm schreiben muss um di Tastatur zu integrieren

hier der Sketch von Doctor Volt ich hoffe das darf man so machen der auf dem Nano laufen soll bei mir leider nicht. Freue michüber jede Hilfe wäre echt eine tolle sache wenn ich das hinbekommen könnten, und man auf disem weg mit ihm sprechen könnte.

#define CLOCK 6 //D-
#define DATA 7  //D+

#include <LiquidCrystal.h>  //Best imported by library manager

const char keymap[] = {
  0, 0,  0,  0,  0,  0,  0,  0,
  0, 0,  0,  0,  0,  0, '`', 0,
  0, 0 , 0 , 0,  0, 'q','1', 0,
  0, 0, 'z','s','a','w','2', 0,
  0,'c','x','d','e','4','3', 0,
  0,' ','v','f','t','r','5', 0,
  0,'n','b','h','g','y','6', 0,
  0, 0, 'm','j','u','7','8', 0,
  0,',','k','i','o','0','9', 0,
  0,'.','/','l',';','p','-', 0,
  0, 0,'\'', 0,'[', '=', 0, 0,
  0, 0,13, ']', 0, '\\', 0, 0,
  0, 0, 0, 0, 0, 0, 127, 0,
  0,'1', 0,'4','7', 0, 0, 0,
  '0','.','2','5','6','8', 0, 0,
  0,'+','3','-','*','9', 0, 0,
  0, 0, 0, 0 };

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup()
{
  Serial.begin(115200);
  pinMode(CLOCK, INPUT_PULLUP); //For most keyboards the builtin pullups are sufficient, so the 10k pullups can be omitted
  pinMode(DATA, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  lcd.begin(20, 4);
  lcd.cursor();
  lcd.blink();
  bitSet(PCICR, PCIE2); // Enable pin change interrupts on pin D0-D7
  bitSet(PCMSK2, CLOCK); // Pin change interrupt on Clock pin
 }

uint8_t lastscan;
uint8_t line = 0, col = 0;


ISR(PCINT2_vect)
{
  uint16_t scanval = 0;
  for(int i = 0; i<11; i++)
  {
    while(digitalRead(CLOCK));
    scanval |= digitalRead(DATA) << i;
    while(!digitalRead(CLOCK));
  }
  scanval >>= 1;
  scanval &= 0xFF;
  Serial.println(scanval, HEX);
  if(lastscan != 0xF0 && scanval != 0xF0)
  switch(scanval)
  {
    case 0x5A: //Enter
      lcd.setCursor(0, ++line & 0x03);
      col = 0;
      break;
    case 0x66: //Backspace
      lcd.setCursor(--col, line);
      lcd.write(' ');
      lcd.setCursor(col, line);
    break;
    default:
      lcd.write(keymap[scanval]);
      col++;
  }
  lastscan = scanval;
  bitSet(PCIFR, PCIF2);
}

void loop()
{
  /*digitalWrite(13, LOW);
  delay(500);  
  digitalWrite(13, HIGH);
  delay(500);*/
}

Vielen Dank

Im englischen Teil des Forum müssen die Beiträge und Diskussionen in englischer Sprache verfasst werden. Deswegen wurde diese Diskussion in den deutschen Teil des Forums verschoben.

mfg ein Moderator.

Der Code sieht eher nicht nach USB-Tastatur aus sondern nach PS2-Tastatur.

Poste den Link zu dem Youtube-Video

Was für eine Tastatur? Wie sieht die aus? Bild posten

Sehr ehrenwert dieses Projekt. Aber hätte das Kind nicht Anspruch auf ein professionelles Gerät, dass sehr genau an seine Möglichkeiten angepasst ist? Das kostet dann tausende Euro aber dafür ist ja die Sozialgemeinschaft der Krankenkassen da in solchen Fällen zu helfen.

Na in dem man Serial.print() im Programm hinzufügt.
vgs

So hier mal der link zum Video bei Youtube

(3) How to Connect a PC Keyboard to an Arduino? - YouTube

Ist einen ältere Dell USB Tastatur

kannst u mir kurz schreiben was ich in den sketch einfügen muss damit ich sehe ob daten von der tasttatur komme .Ich habe von der Progsprache sogut wie noch keine Ahnung sorry.

Ja u hast recht wäre toll wenn sowas die Krankenkasse machen würde gibt es aber so leider nicht und bevor er dan gar nix hat besser sowas !

Original: Connect a USB Keyboard with an Arduino - Hackster.io


Das ist die Tastatur


Das der Aufbau

Hast du ein Oszilloskop zur Verfügung?
Dann könnte man sich den Signalverlauf auf der Clock und Datenleitung anschauen.

Wenn nicht dann kann man das Programm modifzieren um festzustellen ob wenigstens überhaupt irgendein Spannungspegel-Wechsel stattfindet.

Oszi habe ich Geschäft könnte Check morgen Abend mal testen

Ich muss dich über den serial Monitor auch was sehen

Muss ich da extra was einfügen in den Sketch

Wat isn dat fürn deutsch?
Bevor du auf Reply klickst lese dir noch mal durch was du geschrieben hast.

Was mir an dem Code nicht gefällt ist, dass da innerhalb der interrupt-routine auf das LCD geschrieben wird und auf den seriellen Monitor ausgegeben wird.

Das sollte außerhalb der interrupt-routine gemacht werden.
hackster.io ist im allgemeinen eine recht brauchbare Quelle aber der code??? NE!

Dazu muss man den Code quasi komplett umarbeiten.
google mal nach Arduino Uno PS2-keyboard
und poste die links der Fundstellen

Gehts Dir gut?

Ja mir geht es so gut, dass ich nicht einmal im Ansatz verstehe,
warum ein kleines bisschen Mitarbeit des TO mit einer Aufgabenstellung die er auch ohne Programmierkenntnisse machen kann ein Problem darstellen sollte.

Ich habe jetzt mal auf die schnelle die Display-Ausgabe und die serielle Ausgabe aus der ISR herausgezogen. Kann aber aus Erfahrungsmangel nicht einschätzen ob das abarbeiten schnell genug passiert dass das so funktioniert.

#define CLOCK 6 //D-
#define DATA 7  //D+

#include <LiquidCrystal.h>  //Best imported by library manager

volatile uint8_t lastscan;
volatile uint16_t scanval = 0;
volatile boolean scanCodeReceived = false;

uint8_t line = 0, col = 0;

const char keymap[] = {
  0, 0,  0,  0,  0,  0,  0,  0,
  0, 0,  0,  0,  0,  0, '`', 0,
  0, 0 , 0 , 0,  0, 'q', '1', 0,
  0, 0, 'z', 's', 'a', 'w', '2', 0,
  0, 'c', 'x', 'd', 'e', '4', '3', 0,
  0, ' ', 'v', 'f', 't', 'r', '5', 0,
  0, 'n', 'b', 'h', 'g', 'y', '6', 0,
  0, 0, 'm', 'j', 'u', '7', '8', 0,
  0, ',', 'k', 'i', 'o', '0', '9', 0,
  0, '.', '/', 'l', ';', 'p', '-', 0,
  0, 0, '\'', 0, '[', '=', 0, 0,
  0, 0, 13, ']', 0, '\\', 0, 0,
  0, 0, 0, 0, 0, 0, 127, 0,
  0, '1', 0, '4', '7', 0, 0, 0,
  '0', '.', '2', '5', '6', '8', 0, 0,
  0, '+', '3', '-', '*', '9', 0, 0,
  0, 0, 0, 0
};

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  Serial.begin(115200);
  pinMode(CLOCK, INPUT_PULLUP); //For most keyboards the builtin pullups are sufficient, so the 10k pullups can be omitted
  pinMode(DATA, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  lcd.begin(20, 4);
  lcd.cursor();
  lcd.blink();
  bitSet(PCICR, PCIE2); // Enable pin change interrupts on pin D0-D7
  bitSet(PCMSK2, CLOCK); // Pin change interrupt on Clock pin
}


ISR(PCINT2_vect) {
  for (int i = 0; i < 11; i++) {
    while (digitalRead(CLOCK));
    scanval |= digitalRead(DATA) << i;
    while (!digitalRead(CLOCK));
  }
  scanval >>= 1;
  scanval &= 0xFF;

  // Serial.println(scanval, HEX);
  if (lastscan != 0xF0 && scanval != 0xF0) {
    scanCodeReceived = true;
  }
  lastscan = scanval;
  bitSet(PCIFR, PCIF2);
}

void loop() {

  if (scanCodeReceived) {
    Serial.println(scanval, HEX);

    switch (scanval) {
      case 0x5A: //Enter
        lcd.setCursor(0, ++line & 0x03);
        col = 0;
        break;

      case 0x66: //Backspace
        lcd.setCursor(--col, line);
        lcd.write(' ');
        lcd.setCursor(col, line);
        break;

      default:
        lcd.write(keymap[scanval]);
        col++;
    }
    scanCodeReceived = false;
  }
}

vgs

Ok ich checke jetzt erst mal ob von der Tastatur was kommt und dann sehen wir weiter.
ggf. muss ich jemanden finden der mir das programmiert ist Hardware Stromversorgung usw. ist kein Problem für mich. Ich gebe morgen mal Bescheid was rausgekommen ist.

Hast Du mal gelesen, was Du da abfragst?
Wenn Du eine Linkliste haben willst, solltest Du selbst googlen.
Oder Dich so äussern, das keiner auf die Idee kommt das Internet hierher zu kopieren.
Ich hab mal die erste Seite angehangen. Was glaubst Du wieviele da noch kommen?
Arduino Uno PS2-keyboard at DuckDuckGo.pdf (66,1 KB)

Kannst Dich ja schon mal durchklicken...

Ok danke erst mal

Code habe ich mal kopiert und hochgeladen ist soweit mal durch geändert hat sich soweit ich das sagen kann aber nicht. Weder wird etwas im Display noch im Serial Monitor angezeigt das ist doch in der neuen IDE version unten

Wichtig wäre zu wissen, ob das keyboard natives PS2 unterstützt oder nur HID ist.
Was steht auf dem Typenschild auf der Unterseite?


Tastatur

Ich such mal ob ich noch eine ps 2 Tastatur habe

So hier ist eine Code-Version die einfach nur ein flag setzt wenn denn ein Signalpegel stattgefunden hat und dann was in den Seriellen Monitor printed

#define CLOCK 6 //D-
#define DATA 7  //D+

#include <LiquidCrystal.h>  //Best imported by library manager

volatile uint8_t lastscan;
volatile uint16_t scanval = 0;
volatile boolean scanCodeReceived = false;

uint8_t line = 0, col = 0;

const char keymap[] = {
  0, 0,  0,  0,  0,  0,  0,  0,
  0, 0,  0,  0,  0,  0, '`', 0,
  0, 0 , 0 , 0,  0, 'q', '1', 0,
  0, 0, 'z', 's', 'a', 'w', '2', 0,
  0, 'c', 'x', 'd', 'e', '4', '3', 0,
  0, ' ', 'v', 'f', 't', 'r', '5', 0,
  0, 'n', 'b', 'h', 'g', 'y', '6', 0,
  0, 0, 'm', 'j', 'u', '7', '8', 0,
  0, ',', 'k', 'i', 'o', '0', '9', 0,
  0, '.', '/', 'l', ';', 'p', '-', 0,
  0, 0, '\'', 0, '[', '=', 0, 0,
  0, 0, 13, ']', 0, '\\', 0, 0,
  0, 0, 0, 0, 0, 0, 127, 0,
  0, '1', 0, '4', '7', 0, 0, 0,
  '0', '.', '2', '5', '6', '8', 0, 0,
  0, '+', '3', '-', '*', '9', 0, 0,
  0, 0, 0, 0
};

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  Serial.begin(115200);
  while(!Serial);
  Serial.println( F("Setup-Start") );
  Serial.println( F("Test ob überhaupt ein Signalpegel-Wechsel stattfindet") );
  pinMode(CLOCK, INPUT_PULLUP); //For most keyboards the builtin pullups are sufficient, so the 10k pullups can be omitted
  pinMode(DATA, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  lcd.begin(20, 4);
  lcd.cursor();
  lcd.blink();
  bitSet(PCICR, PCIE2); // Enable pin change interrupts on pin D0-D7
  bitSet(PCMSK2, CLOCK); // Pin change interrupt on Clock pin
  Serial.println( F("Pin-Change-Interrupt aktiv") );
  scanval = 0;
}


ISR(PCINT2_vect) {
  scanCodeReceived = true;
/*  
  for (int i = 0; i < 11; i++) {
    while (digitalRead(CLOCK));
    scanval |= digitalRead(DATA) << i;
    while (!digitalRead(CLOCK));
  }
  scanval >>= 1;
  scanval &= 0xFF;

  // Serial.println(scanval, HEX);
  if (lastscan != 0xF0 && scanval != 0xF0) {
    scanCodeReceived = true;
  }
  lastscan = scanval;
  bitSet(PCIFR, PCIF2);
*/  
}


void loop() {

  if (scanCodeReceived) {
    Serial.println("ISR wurde aufgerufen");
    scanCodeReceived = false;
    //delay(500);
  }
}

Und bei der Suche nach PS-2-Codes der hier aus der google-suche ist doch vielversprechend

vgs

Die library PS2KeyAdvanced kann über den library-managr installiert werden

Und im Demo-Code passt auch schon der Interrupt -IO-pin für Arduino Nano

@voxy2
Für diesen Code das LCD abklemmen und USB-Clock auf IO-pin 3 und USB-Data-pin auf IO-pin 4
Dann mal testen ob was im seriellen Monitor ausgegeben wird

/*  Simple keyboard to serial port at 115200 baud

  PS2KeyAdvanced library example

  Advanced support PS2 Keyboard to get every key code byte from a PS2 Keyboard
  for testing purposes.

  IMPORTANT WARNING

    If using a DUE or similar board with 3V3 I/O you MUST put a level translator
    like a Texas Instruments TXS0102 or FET circuit as the signals are
    Bi-directional (signals transmitted from both ends on same wire).

    Failure to do so may damage your Arduino Due or similar board.

  Test History
    September 2014 Uno and Mega 2560 September 2014 using Arduino V1.6.0
    January 2016   Uno, Mega 2560 and Due using Arduino 1.6.7 and Due Board
                    Manager V1.6.6

  This is for a LATIN style keyboard using Scan code set 2. See various
  websites on what different scan code sets use. Scan Code Set 2 is the
  default scan code set for PS2 keyboards on power up.

  Will support most keyboards even ones with multimedia keys or even 24 function keys.

  The circuit:
   * KBD Clock (PS2 pin 1) to an interrupt pin on Arduino ( this example pin 3 )
   * KBD Data (PS2 pin 5) to a data pin ( this example pin 4 )
   * +5V from Arduino to PS2 pin 4
   * GND from Arduino to PS2 pin 3

   The connector to mate with PS2 keyboard is a 6 pin Female Mini-Din connector
   PS2 Pins to signal
    1       KBD Data
    3       GND
    4       +5V
    5       KBD Clock

   Keyboard has 5V and GND connected see plenty of examples and
   photos around on Arduino site and other sites about the PS2 Connector.

 Interrupts

   Clock pin from PS2 keyboard MUST be connected to an interrupt
   pin, these vary with the different types of Arduino

  PS2KeyAdvanced requires both pins specified for begin()

    keyboard.begin( data_pin, irq_pin );

  Valid irq pins:
     Arduino Uno:  2, 3
     Arduino Due:  All pins, except 13 (LED)
     Arduino Mega: 2, 3, 18, 19, 20, 21
     Teensy 2.0:   All pins, except 13 (LED)
     Teensy 2.0:   5, 6, 7, 8
     Teensy 1.0:   0, 1, 2, 3, 4, 6, 7, 16
     Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
     Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
     Sanguino:     2, 10, 11

  Read method Returns an UNSIGNED INT containing
        Make/Break status
        Caps status
        Shift, CTRL, ALT, ALT GR, GUI keys
        Flag for function key not a displayable/printable character
        8 bit key code

  Code Ranges (bottom byte of unsigned int)
        0       invalid/error
        1-1F    Functions (Caps, Shift, ALT, Enter, DEL... )
        1A-1F   Functions with ASCII control code
                    (DEL, BS, TAB, ESC, ENTER, SPACE)
        20-61   Printable characters noting
                    0-9 = 0x30 to 0x39 as ASCII
                    A to Z = 0x41 to 0x5A as upper case ASCII type codes
                    8B Extra European key
        61-A0   Function keys and other special keys (plus F2 and F1)
                    61-78 F1 to F24
                    79-8A Multimedia
                    8B NOT included
                    8C-8E ACPI power
                    91-A0 and F2 and F1 - Special multilingual
        A8-FF   Keyboard communications commands (note F2 and F1 are special
                codes for special multi-lingual keyboards)

    By using these ranges it is possible to perform detection of any key and do
    easy translation to ASCII/UTF-8 avoiding keys that do not have a valid code.

    Top Byte is 8 bits denoting as follows with defines for bit code

        Define name bit     description
        PS2_BREAK   15      1 = Break key code
                   (MSB)    0 = Make Key code
        PS2_SHIFT   14      1 = Shift key pressed as well (either side)
                            0 = NO shift key
        PS2_CTRL    13      1 = Ctrl key pressed as well (either side)
                            0 = NO Ctrl key
        PS2_CAPS    12      1 = Caps Lock ON
                            0 = Caps lock OFF
        PS2_ALT     11      1 = Left Alt key pressed as well
                            0 = NO Left Alt key
        PS2_ALT_GR  10      1 = Right Alt (Alt GR) key pressed as well
                            0 = NO Right Alt key
        PS2_GUI      9      1 = GUI key pressed as well (either)
                            0 = NO GUI key
        PS2_FUNCTION 8      1 = FUNCTION key non-printable character (plus space, tab, enter)
                            0 = standard character key

  Error Codes
     Most functions return 0 or 0xFFFF as error, other codes to note and
     handle appropriately
        0xAA   keyboard has reset and passed power up tests
               will happen if keyboard plugged in after code start
        0xFC   Keyboard General error or power up fail

  See PS2Keyboard.h file for returned definitions of Keys

  Note defines starting
            PS2_KEY_* are the codes this library returns
            PS2_*     remaining defines for use in higher levels

  To get the key as ASCII/UTF-8 single byte character conversion requires use
  of PS2KeyMap library AS WELL.

  Written by Paul Carpenter, PC Services <sales@pcserviceselectronics.co.uk>
*/

#include <PS2KeyAdvanced.h>

/* Keyboard constants  Change to suit your Arduino
   define pins used for data and clock from keyboard */
#define DATAPIN 4
#define IRQPIN  3

uint16_t c;

PS2KeyAdvanced keyboard;


void setup( )
{
// Configure the keyboard library
keyboard.begin( DATAPIN, IRQPIN );
Serial.begin( 115200 );
Serial.println( "PS2 Advanced Key Simple Test:" );
}


void loop( )
{
if( keyboard.available( ) )
  {
  // read the next key
  c = keyboard.read( );
  if( c > 0 )
    {
    Serial.print( "Value " );
    Serial.print( c, HEX );
    Serial.print( " - Status Bits " );
    Serial.print( c >> 8, HEX );
    Serial.print( "  Code " );
    Serial.println( c & 0xFF, HEX );
    }
  }
}

vgs

Ok danke ich komme erst morgen dazu dies zu testen .
:grinning: