Program to greet (via console) the user in response to their tag id

Dependencies:   ID12RFID mbed

Fork of ID12RFID_HelloWorld by Simon Ford

main.cpp

Committer:
bendavis96
Date:
2016-06-17
Revision:
2:7935e9c3e00b
Parent:
1:2c017f3d2d04

File content as of revision 2:7935e9c3e00b:

// Hello World for printing RFID tag numbers

#include "mbed.h"
#include "ID12RFID.h"

Serial pc(USBTX,USBRX);
DigitalOut rled(LED1);
DigitalOut gled(LED2);
DigitalOut bled(LED3);
ID12RFID rfid(PTE1);

int main()
{
    rled = 1;
    bled = 1;
    gled = 1;
    while(1) {

        do {

            switch (rfid.read()) {

                case 22311780 :
                    pc.printf("\rWelcome, Ben\r\n");
                    rled = 0;
                    bled = 1;
                    gled = 1;
                    break;
                case 22320978 :
                    pc.printf("\rWelcome, Joe\r\n");
                    rled = 1;
                    bled = 0;
                    gled = 1;
                    break;
                case 22352757 :
                    pc.printf("\rWelcome, Arthur\r\n");
                    rled = 1;
                    bled = 1;
                    gled = 0;
                    break;
            }
            wait(0.2);
        } while (rfid.readable());

    }


}