C O / Mbed 2 deprecated RFIDcom

Dependencies:   ID12RFID mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ID12RFID.h"
00003 
00004 Serial pc(USBTX, USBRX);
00005 ID12RFID rfid(PTD2); // uart rx
00006 Serial talky(PTC4, PTC3);
00007 
00008 DigitalOut l1(LED1);
00009 DigitalOut l2(LED2);
00010 DigitalOut l3(LED3);
00011 
00012 
00013 
00014 int main() {
00015 l1=1;
00016 l2=1;
00017 l3=1;
00018 
00019     pc.printf("\r Hello BEAUTIFUL!\n");
00020     while(1) {
00021     
00022         if(rfid.readable()&& talky.writeable()) {
00023             int c=rfid.read();
00024             l2=1;
00025             l1=!l1;
00026             wait(0.01);
00027             pc.printf("\r RFID Tag number : %d\n", c);        
00028                
00029 //               l1=!l1;
00030                talky.printf("%d\r ", c);
00031                 wait(0.1);
00032 //            l1=!l1;
00033             l1=!l1;
00034         }
00035         else { 
00036         l1=1;l2=0;}
00037     }
00038 }
00039 //
00040 //DigitalOut l1(LED1);
00041 //DigitalOut l2(LED2);
00042 //DigitalOut l3(LED3);
00043 //
00044 //
00045 //int main() {
00046 //
00047 //l1=1;
00048 //l2=1;
00049 //l3=1;
00050 //    while(1) {
00051 //    if (pc.readable() && talky.writeable()){
00052 //    char c = pc.getc();
00053 //    l1=!l1;
00054 //    talky.putc(c);
00055 //    wait(0.01);
00056 //    l1=!l1;
00057 //    }
00058 //    if (talky.readable() && pc.writeable()){
00059 //    l2=!l2;
00060 //    char c2 = talky.getc();
00061 //    wait(0.01);
00062 //    l2=!l2;
00063 //    pc.putc(c2);
00064 //        }  
00065 //    wait(0.01);
00066 //    }
00067 //}