A program to emulate a cash register/POS system.

Dependencies:   ID12RFID Keypad mbed 4DGL-uLCD-SE

main.cpp

Committer:
mitchpang
Date:
2015-03-11
Revision:
0:c69a3d7bf65a
Child:
1:eeb4a2a8550c

File content as of revision 0:c69a3d7bf65a:

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

ID12RFID rfid(p14); // uart rx
Serial pc(USBTX, USBRX);
Keypad   keypad(p29,p24,p25,p27,p28,p30,p26);




int main()
{
    printf("Hello World\n");
    const int key[]= {5453460, 5469457};
    const char* cost[]= {"$3","$4"};
    const char* item[]= {"milk","bread"};

    int num;
    int i, index=0;

    while(1) {
        if(rfid.readable()) {
            num = rfid.read();
            for(i=0; i<2; i++) {
                if(key[i] == num) {
                    index = i;
                }
            }

            pc.printf("id: %d, cost: %s, item: %s \n", key[index], cost[index], item[index]);
            pc.printf("RFID Tag number : %d\n", num);
        }
        if(keypad.isNewAndPressed()) {
            pc.printf("Keypad button: %c\n", keypad.getKey());
        }
    }
}