The AVR microcontroller boards which are provided with all the basic circuitry for the operation of the microcontroller which has been flashed with the arduino boot-loader are called arduino boards. The arduino can communicate with the other devices using its digital I/O, serial port, I2C port, SPI port etc. The arduino IDE is so simple to use that anyone who has basic knowledge of c programming can quickly get started with it. The project on how to get started with the arduino explains about the steps required to get start with an arduino board.The arduino board used in this project is the arduino pro-mini board and the IDE version of the arduino is 1.0.3 for windows. The Arduino pro-mini board has ATMEGA328 microcontroller inside it which has an internal EEPROM memory of 1Kb.
The image of the arduino pro-mini board and the arduino IDE are shown below;
Fig. 2: Typical Arduino Pro-Mini Board
Fig. 3: Arduino IDE Software Window
Since the arduino pro-mini board has no circuitary for interfacing it with the serial port or the USB port of the PC, an external USB to TTL converter board is required to connect it with the PC. This hardware helps in programming the arduino board and also helps in the serial communication with the USB port of the PC.
Fig. 4: External USB to TTL converter board for programming Arduino and serial communication
It is assumed that the reader has gone through the project how to get started with the arduino and tried out all the things discussed there.The memory card used in this particular project is a 2 GB SD card from Transcend but the code is supposed to work with SD card from all vendors. The SD card operates on 3.3V logic and hence to interface it with a microcontroller which runs on 5V logic one should use a Logic Level Converter. Since the memory card is interfaced using the SPI bus the four channel Logic Level Converter modules which are commonly available in the market can be used. The image of the Logic Level Converter module used in this project is shown in the following image;
Fig. 5: Logic Level Converter Module Circuit
The SD memory card and the low voltage side of the Logic Level Converter should be provided with the 3.3V power supply and for that one can use any 3.3V regulator IC. A bi-color LED is suggested to connect across the 3.3V positive and MISO and MOSI lines of the SD card. The image of the memory card and the required circuitry that has been built for this particular project is shown in the following image. In the image one can see a potentiometer which is actually forms the circuit with an SMD variable regulator IC LM117 underneath it. It is recommended to use LM1117 which is a 3.3V regulator and which does not require other components to set the voltage as shown in the circuit diagram of this project.
Fig. 6: Interfacing SD Memory card using Level Contoller With Arduino
The Arduino pro-mini board has digital pins marked as 2, 3, 4 up to 13. Among the digital pins four pins namely 10, 11, 12 and 13 can be configured as SS, MOSI, MISO and SCK. The MISO of the memory card should be connected to the pin number 11, the MOSI should be connected to the pin number 12 and the SCK should be connected to the pin number 13 of the Arduino pro-min. The SS of the SD card should be connected to the pin which is defined as the SS pin of the Arduino in the code written. The previous projects on how to interface an SD card with the Arduino and how to use SD card to store sensor value discusses more about the details of interfacing the SD card with the Arduino.
The project uses the PS2 connector to connect the Keyboard with the Arduino board. The PS2 connector has a pin for Data and another pin for Clock and using only these two pins the keyboard communicates with the host device. The mouse always has 6 pin mini-DIN male connector for PS2 interface and the host device always has the corresponding female pin. The images and the pin-outs of the PS2 male and female connectors are shown in the following image, the only difference between the PS2 keyboard and mouse connectors are in their color.
The image of the PS2 male pin
Fig. 7: 6 pin mini-DIN Male connector for PS2 interface
The image of the PS2 female pin
Fig. 8: 6 Pin Mini DIN Female Connector Plug for PS2 interface
The pin-out of the PS2 male and female connectors
Fig. 9: Pin-Out Of PS2 Male and Female Connectors
When it comes to connecting the female connector with the circuit board one should be able to identify the pins at the bottom of the PS2 connector and the following image will be helpful.
Fig. 10: Bottom of Mini DIN Female Connector Plug for PS2 interface
The code written for this project uses the custom PS2 library file called “PS2Keyboard.h” which has all the necessary routines for accessing a PS2 mouse and the details of how to use this library to interface a PS2 keyboard is already discussed in a previous project on how to interface the PS2 keyboard with the Arduino and how to connect the PS2 keyboard with LCD using Arduino. There are basically three functions which the user can directly make use in their code and are namely “keyboard.begin()”, keyboard.available() and “mouse.report(data)”.
The Arduino IDE provides a library called <SD.h> which has lot of functions to access the SD memory card. The library is able to access the FAT16 or FAT32 filesystem of the SD card using the AVR microcontroller of the Arduino board so that the files can be read, modify or write. The functions used in this particular project are SD.begin(), SD.open(), file. print(), file.read(), and file.close() from the library <SD.h> and the details regarding them are explained in a previous project on how to interface SD card with Arduino.
As the code runs it first opens a particular file for reading and displays all its content in the Serial Monitor window. It then closes the same file and reopens it in the writing mode. After that the user can type in what all text into the memory card using the PS2 keyboard and they will get saved in it. The next time when the code runs it displays the same data which has been read from the SD card along with the previous data in the same file.
The data are displayed on the Serial monitor window with the help of the functions Serial.begin(),Serial.print() and Serial.println() which are already discussed in previous projects on how to do serial communication with the Arduino, how to send and receive serial data using arduino and how to do serial debugging with the Arduino.
Before compiling the code make sure that the files “PS2Keyboard.h” and “PS2Keyboard.cpp” are kept in the same folder where the .pde file has been saved. When the coding is finished one can verify and upload the code to the Arduino board as explained in the project how to get started with the Arduino.