Eccolo:
#include <PS2Keyboard.h>
#include <SD.h>
#include "PS2Keyboard.h"
#define DATA_PIN 2 //define data pin of the kayboard
PS2Keyboard keyboard;
File myFile; // variable required to hold the file descriptor
const int chipSelect = 10; // the pin number which is need to write on SD card
byte dat;
char c;
void setup()
{
pinMode(10, OUTPUT);
Serial.begin(9600); // initialize the serial port at baud rate 9600
Serial.print("Initializing SD card...");
while(!SD.begin(chipSelect)); // initialize the SD card
Serial.println("card initialized.");
keyboard.begin(DATA_PIN); // initialize the PS2 keyboard
Serial.println("keyboard initialized.");
}
void loop()
{
if(keyboard.available())
{
dat = keyboard.read();
c = dat;
while(!(myFile = SD.open("new.txt", FILE_WRITE))); // open a file for writing
myFile.print(c); // write the string into the file
myFile.close();
Serial.println(c);
}
else;
}
Il problema è quello di inviare i dati al pc.. Quindi forse non è possibile sdoppiare il segnale, per questo motivo ho pensato una cosa.. Si potrebbe usare ciò che ricevo nel DATA PIN per scrivere su Sd e poi farlo uscire inalterato come output da un altro PIN e collegarlo al pc per farci arrivare i dati della tastiera?