Basic example showing how to use an m3pi with the RFID Reader attached

Dependencies:   mbed m3pi ID12RFIDIRQ

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // m3pi RFID Reader Example
00002 
00003 #include "mbed.h"
00004 #include "m3pi.h"     // m3pi robot controls
00005 #include "ID12RFID.h" // RFID reader library
00006 
00007 m3pi m3pi;
00008 
00009 // This is needed to access the RFID Reader...
00010 ID12RFID rfid(p14);
00011 
00012 int main() {
00013 
00014     m3pi.locate(0,0);
00015     m3pi.printf("RFIDRead");
00016 
00017     while (1) {
00018     
00019         // Check if the reader is reading an ID?
00020         if(rfid.readable()) {
00021         
00022             // Get the ID from the reader...
00023             int id = rfid.read();
00024 
00025             // Print it on the LCD...
00026             m3pi.locate(0,1);
00027             m3pi.printf("%d", id);
00028         }
00029     }
00030 }