#include <PS2Keyboard.h>
#include <SD.h>
#include "PS2Keyboard.h"
#define DATA_PIN 2 //define data pin of the keyboard
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(uint8_t dataPin); // 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;
}
and this the wrong
C:\Users\Zomber\Documents\Arduino\sketch_jul15a\sketch_jul15a.ino: In function 'void setup()':
sketch_jul15a:23: error: expected primary-expression before 'dataPin'
keyboard.begin(uint8_t dataPin); // initialize the PS2 keyboard
^
exit status 1
expected primary-expression before 'dataPin'
You cannot, as far as I know, declare a variable in the parameter list of a function and in any case what will its value be ? Declare dataPin and give it a value before trying to use the variable
Take the uint8_t out of the indicated line. Next it will probably still not compile as, as far as I can see, you do not have dataPin but you have DATA_PIN.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.