Hi all,
Please forgive my ignorance but I am still very new to this stuff. Conversely, please respond as if you're talking to a five year old so I can better understand.
Below is my current code and wiring diagram. I've successfully read some RFID cards with a serial print out (using a PN5180 module) and various associated LED activations. Separately, I've been able to get the SSD1306 screen to function and read out simple messages. The problem, to my understanding, is that when I want to do both, I am now out of memory. Apparently, the SDD1305 Adafruit library is the likely culprit. I attempted to perform the same tasks with the simpler U8G2 library but am at a loss for how to set it up. Previously, I've slowly adjusted example files to what I need with varied success.
End state for this project is to have a badge reader that signs out/in a workstation. User scans badge, turns LED from green to red, screen displays workstation #1234 is signed out on date/time and that date/time is logged. User scans badge again, turns LED from red to green, screen displays workstation #1234 is signed in on date/time, and that date/time is logged again.
I should add that I still want to add a RTC and process for storing date/times (probably quantity 10-20).
Any and all input greatly appreciated!
//card includes
#include <PN5180.h>
#include <PN5180ISO15693.h>
//*************************************************************************************
//screen includes
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//*************************************************************************************
#define PN5180_NSS 10
#define PN5180_BUSY 9
#define PN5180_RST 7
PN5180ISO15693 nfc(PN5180_NSS, PN5180_BUSY, PN5180_RST);
//*************************************************************************************
//screen defines
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//*************************************************************************************
//card and screen setup
void setup() {
Serial.begin(115200);
pinMode(4, OUTPUT);
pinMode(2, OUTPUT);
//4 is red
//2 is green
digitalWrite(2, HIGH);
nfc.begin();
nfc.reset();
uint8_t productVersion[2];
nfc.readEEprom(PRODUCT_VERSION, productVersion, sizeof(productVersion));
if (0xff == productVersion[1]) { // if product version 255, the initialization failed
Serial.flush();
exit(-1); // halt
}
//****************screen setup
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Clear the buffer
display.clearDisplay();
display.display();
delay(2000);
testdrawstyles(); // Draw 'stylized' characters
//*****************
}
uint32_t loopCnt = 0;
uint8_t numCard = 1;
const uint8_t maxTags = 16;
bool errorFlag = false;
//SLIX2 Passwords, first is manufacture standard
uint8_t standardpassword[] = {0x0F, 0x0F, 0x0F, 0x0F};
//New Password
uint8_t password[] = {0x12, 0x34, 0x56, 0x78};
//write screen
void testdrawstyles(void) {
display.clearDisplay();
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.println(F("WHERE'S"));
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,17); // Start at top-left corner
display.println(F("THE BEEF!?"));
display.display();
delay(6000);
display.clearDisplay();
display.println(F(" "));
display.display();
}
//*************************************************************************************
//card read
void loop() {
// Multiple inventory
Serial.println(F("----------------------------------"));
Serial.print(F("Loop #"));
Serial.println(loopCnt++);
uint8_t uid[8*maxTags];
ISO15693ErrorCode rc = nfc.getInventoryMultiple(uid, maxTags, &numCard);
if (ISO15693_EC_OK != rc) {
Serial.print(F("Error in getInventory: "));
Serial.println(nfc.strerror(rc));
errorFlag = true;
}
else if(!numCard){
Serial.println("No cards detected.");
}
else{
Serial.print("Inventory successful. Discovered ");
Serial.print(numCard);
Serial.println(" cards.");
for(int i=0; i<numCard; i++){
Serial.print("UID #");
Serial.print(i);
Serial.print("= ");
for (int j=0; j<8; j++) {
uint8_t startAddr = (i*8) + 7 - j;
if(uid[startAddr] < 16) Serial.print("0");
Serial.print(uid[startAddr], HEX); // LSB is first
if (j < 2) Serial.print(":");
}
Serial.println();
}
//green to red
if(digitalRead(2)==HIGH)
{
digitalWrite(2, LOW);
digitalWrite(4, HIGH);
}
//red to green
else
{
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
}
}
Serial.println(F("----------------------------------"));
delay(1000);
}

