Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int count = 0; // count = 0
- int i;
- char input[12]; // character array of size 12
- boolean flag = 0;
- // flag =0
- boolean comparetag(char x[12], char bb[12]) {
- boolean ff = false;
- int fg = 0;
- for (int cc = 0; cc < 12; cc++) {
- if (x[cc] == bb[cc]) {
- fg++;
- }
- }
- if (fg == 12) {
- ff = true;
- }
- return ff;
- }
- struct Node {
- char x[12];
- struct Node *next;
- };
- struct Node* X;
- struct Node* point;
- void printList(struct Node *n) {
- while (n != NULL) {
- Serial.print(n->x);
- n = n->next;
- }
- }
- struct Node* Shopping(char[]) {
- Serial.print(input);
- // Print RFID tag number
- Serial.print("Welcome User");
- Serial.println();
- Serial.print("Start Shopping ");
- struct Node* head = NULL;
- head = (struct Node*) malloc(sizeof(struct Node));
- return head;
- }
- void setup() {
- Serial.begin(9600);
- }
- void loop() {
- if (flag == 0) {
- if (Serial.available()) {
- count = 0;
- while (Serial.available() && count < 12) // Read 12 characters and store them in input array
- {
- input[count] = Serial.read();
- count++;
- delay(5);
- }
- if (comparetag(input, "1B006AFA9F14")) {
- flag = 1;
- point, X = Shopping(input);
- } else {
- Serial.println("not Registered User");
- }
- }
- } else {
- int c = 0;
- if (Serial.available()) {
- while (Serial.available() && c < 12) // Read 12 characters and store them in input array
- {
- Serial.print("Taking Input");
- X->x[c] = Serial.read();
- c++;
- delay(5);
- }
- struct Node* second = NULL;
- second = (struct Node*) malloc(sizeof(struct Node));
- second = NULL;
- X->next = second;
- X = second;
- }
- }
- printList(point);
- }
Add Comment
Please, Sign In to add comment