fabianhemmert
Published © CC BY

DataTouch: Tangible Presentations

A presentation system based on RFID-reading rings, controlling the slides by picking up objects and walking on the stage. No clicker.

IntermediateShowcase (no instructions)3,828
DataTouch: Tangible Presentations

Things used in this project

Story

Read more

Code

RFID Detection

Arduino
This code runs on the Arduno Mega inside the RFID-reading pedestal. It detects RFID tags put ("PUT" via Serial) on and taken ("TKN") off each of the three RFID readers connected to it.
unsigned long pulse_width;

int ledPin1 = 2;
int ledPin2 = 3;
int ledPin3 = 4;
int ledPin4 = 5;
int ledPin5 = 6;

/*
int vibPin  = 7;

int pirPin1 = 8;
int pirPin2 = 9;
int pirPin3 = 10;
int pirPin4 = 11;
int pirPin5 = 12;
*/

int triggerPin = 7;
int monitorPin = 8;


void setup() {

  delay(250);
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);
  Serial3.begin(9600);

  delay(250);
  
/*
  pinMode(vibPin,OUTPUT); // vibration motor

  pinMode(pirPin1,INPUT); // PIR 1
  pinMode(pirPin2,INPUT); // PIR 2
  pinMode(pirPin3,INPUT); // PIR 3
  pinMode(pirPin4,INPUT); // PIR 4
  pinMode(pirPin5,INPUT); // PIR 5
  */

  pinMode(ledPin1,OUTPUT); 

  pinMode(triggerPin, OUTPUT); 
  pinMode(monitorPin, INPUT); 
  digitalWrite(triggerPin, LOW); 


  digitalWrite(ledPin1,LOW);

//  Serial.println("Datatouch 0.5");

}

String id1 = "";
String id2 = "";
String id3 = "";

String old_id1 = "";
String very_old_id1 = "";
String old_id2 = "";
String very_old_id2 = "";
String old_id3 = "";
String very_old_id3 = "";

void touchDown() {
  
/*
      digitalWrite(vibPin, HIGH);
      delay(200);
      digitalWrite(vibPin, LOW);
*/
}


void pickUp() {

/*
      digitalWrite(vibPin, HIGH);
      delay(50);
      digitalWrite(vibPin, LOW);
*/

}


void loop() {


pulse_width = pulseIn(monitorPin, HIGH); // Count how long the pulse is high in microseconds
  if(pulse_width != 0){ // If we get a reading that isn't zero, let's print it
        pulse_width = pulse_width/10; // 10usec = 1 cm of distance for LIDAR-Lite
  String s;    
    Serial.println("#DIST:"+String(pulse_width) + ";"); // Print the distance
  }


//  digitalWrite(ledPin1,LOW);
  
  delay(200);


  very_old_id1 = old_id1;
  old_id1 = id1;
  id1 = "";

// Serial.println("voi: "+very_old_id1+"\t | "+"oi: "+old_id1+"\t | "+"i: "+id1+" * ");


  while (Serial1.available() > 0) {
    byte inByte = (byte)Serial1.read();
    id1 = id1 + inByte;
  }
  if (id1.length() > 8) {
    Serial.flush();

    if ((very_old_id1 == "") && (old_id1 == ""))  {
      Serial.println("#RFID1:"+id1+" PUT;");
      touchDown();
    }

  }

  if ((very_old_id1.length() > 8) && (old_id1 == "") && (id1 == ""))  {
      Serial.println("#RFID1:"+very_old_id1+" TKN;");
      pickUp();
  }


  very_old_id2 = old_id2;
  old_id2 = id2;
  id2 = "";

  //Serial.println("voi: "+very_old_id2+"\t | "+"oi: "+old_id2+"\t | "+"i: "+id2+" * ");

  while (Serial2.available() > 0) {
    byte inByte = (byte)Serial2.read();
    id2 = id2 + inByte;
  }
  if (id2.length() > 8) {
    Serial.flush();

    if ((very_old_id2 == "") && (old_id2 == ""))  {
      Serial.println("#RFID2:"+id2+" PUT;");
      touchDown();
    }

  }

  if ((very_old_id2.length() > 8) && (old_id2 == "") && (id2 == ""))  {
      Serial.println("#RFID2:"+very_old_id2+" TKN;");
      pickUp();
  }


  very_old_id3 = old_id3;
  old_id3 = id3;
  id3 = "";

  //Serial.println("voi: "+very_old_id3+"\t | "+"oi: "+old_id3+"\t | "+"i: "+id3+" * ");

  while (Serial3.available() > 0) {
    byte inByte = (byte)Serial3.read();
    id3 = id3 + inByte;
  }
  if (id3.length() > 8) {
    Serial.flush();

    if ((very_old_id3 == "") && (old_id3 == ""))  {
      Serial.println("#RFID3:"+id3+" PUT;");
      touchDown();
    }

  }

  if ((very_old_id3.length() > 8) && (old_id3 == "") && (id3 == ""))  {
      Serial.println("#RFID3:"+very_old_id3+" TKN;");
      pickUp();
  }



if (millis() > 10000) {
  //delay(100000);
}

  
}

Credits

fabianhemmert

fabianhemmert

1 project • 0 followers
Contact

Comments