Attendance Tracker
Attendance is generally taken once at the beginning of a class. Teachers use various methods to track entries and exits during class time. Attendance tracking can all be automated using an RFID Reader and RFID Tags. Students tap their RFID Tag on the RFID Reader to record when they enter and exit the classroom.
In this project, you will track student arrivals, exits, and their overall time in the classroom.

Setup
Before getting started, make sure you have the following parts.
Write code (Java)
Copy the code below into a new Java project. If you need a reminder of how to do this, revisit the Getting Started Course. Insert the code below.
Not your programming language? Set your preferences so we can display relevant code examples
package attendance;
//Add Phidgets Library
import com.phidget22.*;
public class Attendance {
public static void main(String[] args) throws Exception {
//Create
RFID rfid = new RFID();
//Open
rfid.open(1000);
//Use your Phidget
while (true) {
if (rfid.getTagPresent()) {
System.out.println(rfid.getLastTag().tagString);
}
Thread.sleep(150);
}
}
}
//Add Phidgets Library
import com.phidget22.*;
public class Attendance {
public static void main(String[] args) throws Exception {
//Create
RFID rfid = new RFID();
//Open
rfid.open(1000);
//Use your Phidget
while (true) {
if (rfid.getTagPresent()) {
System.out.println(rfid.getLastTag().tagString);
}
Thread.sleep(150);
}
}
}
Write code (Python)
Copy the code below into a new Python project. If you need a reminder of how to do this, revisit the Getting Started Course. Insert the code below.
Not your programming language? Set your preferences so we can display relevant code examples
#Add Phidgets Library
from Phidget22.Phidget import *
from Phidget22.Devices.RFID import *
#Required for sleep statement
import time
#Create
rfid = RFID()
#Open
rfid.openWaitForAttachment(1000)
#Use your Phidgets
while (True):
if(rfid.getTagPresent()):
print(rfid.getLastTag()[0])
time.sleep(0.15)
Write code (C#)
Copy the code below into a new C# project. If you need a reminder of how to do this, revisit the Getting Started Course. Insert the code below.
Not your programming language? Set your preferences so we can display relevant code examples
//Add Phidgets Library
using Phidget22;
namespace AttendanceRFID{
class Program{
static void Main(string[] args){
//Create
RFID rfid = new RFID();
//Open
rfid.Open(1000);
//Use your Phidgets
while(true){
if(rfid.TagPresent){
Console.WriteLine(rfid.GetLastTag().TagString);
}
System.Threading.Thread.Sleep(150);
}
}
}
}
Write code (Swift)
Copy the code below into a new Swift project. If you need a reminder of how to do this, revisit the Getting Started Course. Insert the code below.
Not your programming language? Set your preferences so we can display relevant code examples
import Cocoa
import Phidget22Swift
class ViewController: NSViewController {
@IBOutlet weak var rfidLabel: NSTextField!
// Create
let rfid = RFID()
override func viewDidLoad() {
super.viewDidLoad()
do {
// Subscribe to event
let _ = rfid.tag.addHandler(tag_change)
// Open
try rfid.open()
} catch {
print(error)
}
}
func tag_change(sender:RFID, data: (tag: String, proto: RFIDProtocol)) {
DispatchQueue.main.async {
// Use information from your Phidget to change label
self.rfidLabel.stringValue = String(data.tag)
}
}
}
Track Attendance
- Modify the code so each tag is assigned a student’s name. Print the name instead of the tag identifier.
- Modify code to track whether the student is entering or exiting the classroom when their tag is tapped.