Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- #include <hd44780.h>
- #include <hd44780ioClass/hd44780_pinIO.h>
- //Display PinSetup
- //const int rs = 12, en = 11, db4 = 10, db5 = 9, db6 = 8, db7 = 7;
- //Piazo Pin Setup
- const int buzzer = 2;
- int PowerOn = 0;
- hd44780_pinIO lcd(12, 11, 10, 9, 8, 7);
- const int LCDCols = 20;
- const int LCDRow = 4;
- #define LCD_COLS 20
- #define LCD_ROWS 4
- #define HD44780_LCDOBJECT
- String HITAG1 = "h";
- String HITAG2 = "H";
- String EM4102 = "U";
- String EM4150 = "T";
- String ver;
- String id;
- String lastscan;
- String idshort;
- String MTid;
- void setup() {
- pinMode(buzzer, OUTPUT);
- Serial1.begin(9600);
- Serial1.setTimeout(50);
- lcd.begin(20, 4);
- }
- void loop()
- {
- if ( ( (PowerOn) == 1 ) && ( (ver.length()) >= 4 ) )
- {
- Scannen();
- }
- else VersionCheck();
- }
- //Ruft die Version des Kekses ab und Speichert ihn als String ver
- String VersionCheck () { Serial.println("Version");
- digitalWrite(buzzer, HIGH);
- delay(800);
- digitalWrite(buzzer, LOW);
- lcd.print ("Scanner 01");
- lcd.setCursor(0,1);
- Serial1.write("v");
- while (!Serial1.available())
- {
- }
- ver = Serial1.readString();
- ver.trim();
- lcd.print(String(ver));
- delay(1500);
- PowerOn=1;
- return (ver);
- }
- //Scannt die ID und übergibt den String
- String Scannen()
- {
- Serial1.write("rid");
- while (!Serial1.available())
- {
- Serial.println("while");
- }
- id = Serial1.readString();
- id.trim();
- Serial.println(id);
- Serial1.flush();
- if ((id.length()) > 4 && id != lastscan )
- {
- lcd.setCursor(0,1);
- lcd.print(" ");
- lcd.setCursor(0,1);
- digitalWrite(buzzer, HIGH);
- delay(50);
- digitalWrite(buzzer, LOW);
- lcd.print("ID:" + id);
- lcd.setCursor(0,1);
- Serial.println("SCAN1");
- idshort = id;
- idshort.remove(0,1);
- if ( id.startsWith(HITAG1) )
- {
- lcd.setCursor(0,3);
- lcd.print("Typ: HITAG 1");
- lcd.setCursor(0,1);
- }
- else if ( id.startsWith(HITAG2) )
- {
- lcd.setCursor(0,3);
- lcd.print("Typ: HITAG 2");
- lcd.setCursor(0,1);
- }
- else if ( id.startsWith(EM4102) )
- {
- lcd.setCursor(0,2);
- lcd.print("MTID:" + byte0i);
- lcd.setCursor(0,3);
- lcd.print("Typ: EM4102");
- lcd.setCursor(0,1);
- }
- else if ( id.startsWith(EM4150) )
- {
- lcd.setCursor(0,3);
- lcd.print("Typ: EM4150");
- lcd.setCursor(0,1);
- }
- else {
- lcd.setCursor(0,3);
- lcd.print("Typ: UNBEKANNT");
- lcd.setCursor(0,1);
- }
- }
- else if ( ((id.length()) <= 4 ) && id != lastscan)
- {
- lcd.setCursor(0,1);
- lcd.print("KEIN TAG ERKANNT!");
- lcd.setCursor(0,3);
- lcd.print(" ");
- lcd.setCursor(0,1);
- }
- lastscan = id;
- return id;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement