I am a student living in a student house together with 15 others. I am trying to make a attendance system that will display on a screen who is home and who is not. I thought it was a great plan to give everyone a RFID tag, so when they come home or leave they can check in and check out. This will than be represented on a screen displaying green or red circles (using processing).
I have used part of the code from https://www.youtube.com/channel/UC6LO26f_9qwysjvSHdVmfrQ and https://github.com/InfinityWorldHI/RFID_Excel for the arduino code.
I only programmed processing for the first two housemates. However when check in or check out both of the circles change color. I would like to have 2 rows of 8 circles that can change from red to green and the other way around to see if somebody is home.
My arduino program outputs the room nummer "," 1 or 0 (as checked in or checked out) output for example = 11,1.
The processing program will than draw a green or red circle depending on checking in or checking out.
Here is my processing code:
Arduino code (where it outputs to the serial port):
if(NumbCard[j] == 1 && statu[s] == 0 && Number == 11) {
statu[s]=1;
NumbCard[j]=0;
Serial.print(Number);
Serial.print(",");
Serial.println(1);
//Serial.println("is uitgecheckt");
//write led uit
}
else if(NumbCard[j] == 1 && statu[s] == 0 && Number == 22) {
statu[s]=1;
NumbCard[j]=0;
Serial.print(Number);
Serial.print(",");
Serial.println(1);
//Serial.println("is uitgecheckt");
//write led uit
}
Processing code to make the circles:
import processing.serial.*;
// ControlP5 Example 1 : Basic UI elements
import controlP5.*; // import controlP5 library
ControlP5 controlP5; // controlP5 object
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
int end = 10; // Linefeed in ASCII
String myString = null;
int i =0;
PShape led_on, led_off;
String persoon_status;
color [] colors = new color[2];
void setup() {
colors[0] = color(0,255,0);
colors[1] = color(255,0,0);
//change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial (this, Serial.list()[0], 9600);
//led_on = createShape(RECT,10,70,40,40,40);
size(800,800);
}
void draw() {
background(255);
do{
myString = myPort.readStringUntil(end);
if (myString != null) {
println(myString);
}
}
while (myPort.available() > 0); {
if(myString != null && myString.trim().equals("11,1") == true) {
fill(colors[1]);
} else {
if (myString != null && myString.trim().equals("11,0") == true)
fill(colors[0]);
else{
rect(10,70,40,40,40);
}
}
if(myString != null && myString.trim().equals("22,1") == true){
fill(colors[1]);
} else {
if(myString != null && myString.trim().equals("22,0") == true)
fill(colors[0]);
else {
rect(10,130,40,40,40);
}
}
}
}
I think I am close by to getting to the end, however I could not figure this problem out.
Could someone point me in the correct direction?
Please feel free to ask me for more information.
Your help would be really appreciated!