bangnaga

Arduino Baca_Taq_RFID_

Jun 20th, 2013
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define LED_PIN 13
  2. #include <SoftwareSerial.h>
  3. SoftwareSerial RFID(2, 3);
  4. String Teks;
  5. String TeksCek;
  6. char c;
  7. void setup()
  8. {
  9. Serial.begin(9600);
  10. RFID.begin(9600);
  11. pinMode(LED_PIN, OUTPUT); //Sets LED pin as output
  12. digitalWrite(LED_PIN, LOW); //Turn off LED
  13. }
  14.  
  15.  
  16. void loop()
  17. {
  18. while(RFID.available()>0){
  19. delay(5);
  20. digitalWrite(LED_PIN, HIGH); //Turn on LED
  21. c=RFID.read();
  22. Teks += c;
  23. }
  24. if(Teks.length()>10) Cek();
  25. Teks="";
  26.  
  27. }
  28.  
  29. void Cek()
  30. {
  31. Teks=Teks.substring(1,11);
  32.  if (TeksCek != Teks) {
  33.     Serial.println("Tag RFID anda : "+Teks);
  34.     digitalWrite(LED_PIN, LOW); //Turn off LED
  35.     TeksCek = Teks;
  36.   }
  37. }
RAW Paste Data