Pages: [1]   Go Down
Author Topic: Logitech Wireless Keyboard/Reciver  (Read 873 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I´m new to this forum and I would appreciate some input on my problem,

Im trying to use a C-BG17-DUAL logitech reciver with my arduino, but I have runned into some problems. I use the ps/2 cable
and have connected the clock signal and data cables to the digital inputs 3 and 4 and the power and ground into 5v and GND. The
reciver starts up nice. But when I try to pair the reciver with the keyboard it dissconnects after just a second.

I have used this sketch, I´m afraidthat there is some special setup och handshake nessesary between the arduino and the wireless-reciver. Any ideas or tips on how to move on?

Thanks a lot in advance
Mattias W.

Code:
/*
 * an arduino sketch to interface with a ps/2 keyboard.
 * Also uses serial protocol to talk back to the host
 * and report what it finds. Used the ps2 library.
 */

#include <ps2.h>

/*
 * Pin 5 is the ps2 data pin, pin 6 is the clock pin
 * Feel free to use whatever pins are convenient.
 */

PS2 kbd(3, 4);

void kbd_init()
{
  char ack;

  kbd.write(0xff);  // send reset code
  ack = kbd.read();  // byte, kbd does self test
  ack = kbd.read();  // another ack when self test is done
}

void setup()
{
  Serial.begin(9600);
  kbd_init();
}

/*
 * get a keycode from the kbd and report it back to the
 * host via the serial line.
 */
void loop()
{
  unsigned char code;
  
  for (;;) { /* ever */  
    /* read a keycode */
    code = kbd.read();
    /* send the data back up */
    Serial.println(code, HEX);
   // delay(20);  /* twiddle */
  }
}

Moderator edit: [code] [/code] tags added.
« Last Edit: December 28, 2012, 04:03:18 am by Coding Badly » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 223
Posts: 13870
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

please use the # button above the smileys when posting code . You will get appropriate tags that makes reading much easier .

How do you power the system? the Logitech may draw more current than you can give...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

Thanks for letting me know about the #.

I will try to supply the current externaly, but the set up right now is:

The reciver is powered directly through the arduino 5v ., the arduino is connected through the usb cable. The remote keyboard is powered through batteries, but they are new, and I can inisiate the pairing from the keyboard (there are some led´s on the reciver blinking and is lit for a short while but then 2 of the leds,the ones indicating a connection is established, are turned off again.)
 To me it seems to be a problem when this code is executed kbd_init method:
Code:
void kbd_init()
{
  char ack;

 [b] kbd.write(0xff);  [/b] // send reset code
  ack = kbd.read();  // byte, kbd does self test
  ack = kbd.read();  // another ack when self test is done
}
,but I´m not sure at all.

Thanks!
Any other ideas?
/Mattias
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 223
Posts: 13870
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I;m not sure either as I cannot redo your experiments smiley-wink

But you should at least check the values you get from
ack = kbd.read();

print them like
Serial.println(ack, DEC);

to see what you got. I may or may not be an ACKnowledge char at all...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, thankyou!

I runned this code

Code:
  ack = kbd.read();  // byte, kbd does self test
  Serial.println(ack, DEC);
  ack = kbd.read();  // another ack when self test is done
  Serial.println(ack, DEC);

and recived:
-6
and
-86

Any idea´s ?

Best regards
Mattias
Logged

Pages: [1]   Go Up
Jump to: