Hi everyone, in this tutorial i am going to show how to build a wireless keyboard with arduino and bluetooth that allows to write remotely to our Pc with Os windows.
See video
The program only allows to send the following letters, due to limitations of the library used.:
Alphanumeric characters in lower and uppercase
Following is the pin-out of the Connector. There are 4 wires coming
from the keyboard and their connections to arduino Digital pins are as follows.
PS2 connector - Arduino One
Downlad the Ps2Keyboard and import to the new sketch.
#include <PS2Keyboard.h>
Next step we are going to connect the bluetooth module...
Lets use the pins 4 and 5 of the arduin for the serial communication, so there is to import the library SoftwareSerial:
[code]
#include <SoftwareSerial.h>
[/code]
Create an object called blue and set the data rate in 9600.
[code]
SoftwareSerial blue(4,5); //Rx,Tx
blue.begin(9600);
[/code]
The full code is:
[code]
#include <PS2Keyboard.h>
#include <SoftwareSerial.h>
char rec;
SoftwareSerial blue(4,5); //Rx,Tx
const int PinData = 3;
const int PinClock = 2;
PS2Keyboard teclado;
void setup()
{
delay(1000);
teclado.begin(PinData, PinClock);
blue.begin(9600);
}
void loop()
{ // If the keyboard is available
if (teclado.available())
{ // Reads the pressed key
char c = teclado.read(); // Checks some special keys
if (c == PS2_ENTER)
{
blue.println("ent");
}
else if (c == PS2_TAB)
{
blue.println("tab");
}
else if (c == PS2_ESC)
{
blue.println("esc");
}
else if (c == PS2_BACKSPACE)
{
blue.println("bsp");
}
else if (c == PS2_PAGEDOWN)
{
blue.println("pgd");
}
else if (c == PS2_PAGEUP)
{
blue.println("pgu");
}
else if (c == PS2_LEFTARROW)
{
blue.println("lft");
}
else if (c == PS2_RIGHTARROW)
{
blue.println("rgt");
}
else if (c == PS2_UPARROW)
{
blue.println("upk]");
}
else if (c == PS2_DOWNARROW)
{
blue.println("dwn");
}
else if (c == PS2_DELETE)
{
blue.println("del");
}
else
{ // Print the normal characters
blue.println(c);
}
}
}
[/code]
Download here the code for arduino.
Next step receive the keys send...
For receiving the characters send by the keyboard we need a program that capture the data and send the keys to the desired program in our Pc. Download this program and follow the next steps for a correct communication between our Pc and the bluetooth module:
Download here the program in visual basic 2010.
I hope you liked this project and vote for it in the sensor contest.
If you have any suggestions, comments please let me know it.