Rfid to keyboard
hi all.
i need mifare uid keyboard using arduini micro.
i use rc522 library , response using serial.print.
the problem m not able send data keyboard emulating it.
this code
<code>
/*
* mfrc522 - library use arduino rfid module kit 13.56 mhz tags spi w , r cooqrobot.
* library file mfrc522.h has wealth of useful info. please read it.
* functions documented in mfrc522.cpp.
*
* based on code dr.leong ( www.b2cqshop.com )
* created miguel balboa (circuitito.com), jan, 2012.
* rewritten søren thing andersen (access.thing.dk), fall of 2013 (translation english, refactored, comments, anti collision, cascade levels.)
* released public domain.
*
* sample program showing how read data picc using mfrc522 reader on arduino spi interface.
*----------------------------------------------------------------------------- empty_skull
* aggiunti pin per arduino mega
* add pin configuration arduino mega
* http://mac86project.altervista.org/
----------------------------------------------------------------------------- nicola coppola
* pin layout should follows:
* signal pin pin pin
* arduino uno arduino mega mfrc522 board
* ------------------------------------------------------------
* reset 9 5 rst
* spi ss 10 53 sda
* spi mosi 11 52 mosi
* spi miso 12 51 miso
* spi sck 13 50 sck
*
* reader can found on ebay around 5 dollars. search "mf-rc522" on ebay.com.
*/
#include <spi.h>
#include <mfrc522.h>
#define ss_pin 10
#define rst_pin 5
mfrc522 mfrc522(ss_pin, rst_pin); // create mfrc522 instance.
void setup() {
serial.begin(115200); // initialize serial communications pc
spi.begin(); // init spi bus
mfrc522.pcd_init(); // init mfrc522 card
keyboard.begin();
}
void loop() {
// new cards
if ( ! mfrc522.picc_isnewcardpresent()) {
return;
}
// select 1 of cards
if ( ! mfrc522.picc_readcardserial()) {
return;
}
(byte = 0; < mfrc522.uid.size; i++) {
serial.print(mfrc522.uid.uidbyte < 0x10 ? " 0" : " ");
keyboard.print((mfrc522.uid.uidbyte < 0x10 ? " 0" : " "));
serial.print(mfrc522.uid.uidbyte, hex);
keyboard.print((mfrc522.uid.uidbyte < 0x10 ? " 0" : " "));
}
serial.println();
}
</code>
on pc text spaces. think casting problem, s true? how can solve that?
thanks
i need mifare uid keyboard using arduini micro.
i use rc522 library , response using serial.print.
the problem m not able send data keyboard emulating it.
this code
<code>
/*
* mfrc522 - library use arduino rfid module kit 13.56 mhz tags spi w , r cooqrobot.
* library file mfrc522.h has wealth of useful info. please read it.
* functions documented in mfrc522.cpp.
*
* based on code dr.leong ( www.b2cqshop.com )
* created miguel balboa (circuitito.com), jan, 2012.
* rewritten søren thing andersen (access.thing.dk), fall of 2013 (translation english, refactored, comments, anti collision, cascade levels.)
* released public domain.
*
* sample program showing how read data picc using mfrc522 reader on arduino spi interface.
*----------------------------------------------------------------------------- empty_skull
* aggiunti pin per arduino mega
* add pin configuration arduino mega
* http://mac86project.altervista.org/
----------------------------------------------------------------------------- nicola coppola
* pin layout should follows:
* signal pin pin pin
* arduino uno arduino mega mfrc522 board
* ------------------------------------------------------------
* reset 9 5 rst
* spi ss 10 53 sda
* spi mosi 11 52 mosi
* spi miso 12 51 miso
* spi sck 13 50 sck
*
* reader can found on ebay around 5 dollars. search "mf-rc522" on ebay.com.
*/
#include <spi.h>
#include <mfrc522.h>
#define ss_pin 10
#define rst_pin 5
mfrc522 mfrc522(ss_pin, rst_pin); // create mfrc522 instance.
void setup() {
serial.begin(115200); // initialize serial communications pc
spi.begin(); // init spi bus
mfrc522.pcd_init(); // init mfrc522 card
keyboard.begin();
}
void loop() {
// new cards
if ( ! mfrc522.picc_isnewcardpresent()) {
return;
}
// select 1 of cards
if ( ! mfrc522.picc_readcardserial()) {
return;
}
(byte = 0; < mfrc522.uid.size; i++) {
serial.print(mfrc522.uid.uidbyte < 0x10 ? " 0" : " ");
keyboard.print((mfrc522.uid.uidbyte < 0x10 ? " 0" : " "));
serial.print(mfrc522.uid.uidbyte, hex);
keyboard.print((mfrc522.uid.uidbyte < 0x10 ? " 0" : " "));
}
serial.println();
}
</code>
on pc text spaces. think casting problem, s true? how can solve that?
thanks
try this:
code: [select]
serial.print(mfrc522.uid.uidbyte < 0x10 ? " 0" : " ");
serial.print(mfrc522.uid.uidbyte, hex);
keyboard.print((mfrc522.uid.uidbyte < 0x10 ? " 0" : " "));
keyboard.print((mfrc522.uid.uidbyte, hex);
Arduino Forum > Using Arduino > Programming Questions > Rfid to keyboard
arduino
Comments
Post a Comment