Guest User

Untitled

a guest
Oct 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. int count = 0; // count = 0
  2. int i;
  3. char input[12]; // character array of size 12
  4. boolean flag = 0;
  5. // flag =0
  6.  
  7. boolean comparetag(char x[12], char bb[12]) {
  8. boolean ff = false;
  9. int fg = 0;
  10. for (int cc = 0; cc < 12; cc++) {
  11. if (x[cc] == bb[cc]) {
  12. fg++;
  13. }
  14. }
  15. if (fg == 12) {
  16. ff = true;
  17. }
  18. return ff;
  19. }
  20.  
  21. struct Node {
  22. char x[12];
  23. struct Node *next;
  24. };
  25.  
  26. struct Node* X;
  27. struct Node* point;
  28.  
  29. void printList(struct Node *n) {
  30. while (n != NULL) {
  31. Serial.print(n->x);
  32. n = n->next;
  33. }
  34. }
  35.  
  36. struct Node* Shopping(char[]) {
  37.  
  38. Serial.print(input);
  39. // Print RFID tag number
  40. Serial.print("Welcome User");
  41. Serial.println();
  42.  
  43. Serial.print("Start Shopping ");
  44.  
  45. struct Node* head = NULL;
  46. head = (struct Node*) malloc(sizeof(struct Node));
  47.  
  48. return head;
  49.  
  50. }
  51.  
  52. void setup() {
  53. Serial.begin(9600);
  54. }
  55.  
  56. void loop() {
  57.  
  58. if (flag == 0) {
  59. if (Serial.available()) {
  60. count = 0;
  61. while (Serial.available() && count < 12) // Read 12 characters and store them in input array
  62. {
  63. input[count] = Serial.read();
  64. count++;
  65. delay(5);
  66. }
  67.  
  68. if (comparetag(input, "1B006AFA9F14")) {
  69. flag = 1;
  70.  
  71. point, X = Shopping(input);
  72. } else {
  73. Serial.println("not Registered User");
  74. }
  75. }
  76. } else {
  77. int c = 0;
  78. if (Serial.available()) {
  79. while (Serial.available() && c < 12) // Read 12 characters and store them in input array
  80. {
  81. Serial.print("Taking Input");
  82. X->x[c] = Serial.read();
  83. c++;
  84. delay(5);
  85. }
  86. struct Node* second = NULL;
  87. second = (struct Node*) malloc(sizeof(struct Node));
  88. second = NULL;
  89.  
  90. X->next = second;
  91. X = second;
  92.  
  93. }
  94. }
  95. printList(point);
  96. }
Add Comment
Please, Sign In to add comment