#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <WiFi.h>
// WiFi credentials
const char* ssid = "Wokwi-GUEST"; // Set your SSID here
const char* password = ""; // Set your WiFi password here
// Define ILI9341 pins
#define TFT_CLK 18
#define TFT_MISO 21
#define TFT_MOSI 5
#define TFT_CS 15
#define TFT_DC 4
#define TFT_RST 2
// Define SSD1306 pins and constants
#define OLED_SDA 13
#define OLED_SCL 12
#define OLED_RESET 2
#define SSD1306_I2C_ADDRESS 0x3D
#define WIDTH 320
#define HEIGHT 240
// Create ILI9341 display object
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST, TFT_CLK, TFT_MISO, TFT_MOSI);
// Create SSD1306 display object
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
// Simulated attendance data
int totalStudents = 50;
int presentStudents = 0;
void setup() {
// Initialize displays
tft.begin();
tft.setRotation(1);
display.begin(SSD1306_I2C_ADDRESS, OLED_SDA, OLED_SCL);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Clear the screens
tft.fillScreen(ILI9341_BLACK);
display.clearDisplay();
// Display text on the SSD1306 OLED
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Fingerprint System");
display.display();
// Display text on the ILI9341 TFT LCD
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setCursor(10, 10);
tft.println("Attendance System");
}
void loop() {
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
tft.drawPixel(x, y, x * y);
}
}
// Simulate fingerprint sensor input
bool isFingerprintMatch = random(2); // Simulate fingerprint match (1 for match, 0 for no match)
if (isFingerprintMatch) {
presentStudents++;
}
// Update the attendance information on both screens
updateAttendanceScreens();
delay(1000); // Example: wait 1 second between checks
}
void updateAttendanceScreens() {
// Clear the screens
tft.fillScreen(ILI9341_BLACK);
display.clearDisplay();
// Display text on the SSD1306 OLED
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print("Present: ");
display.print(presentStudents);
display.print(" / ");
display.print(totalStudents);
display.display();
// Display text on the ILI9341 TFT LCD
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setCursor(10, 10);
tft.print("Present: ");
tft.print(presentStudents);
tft.print(" / ");
tft.print(totalStudents);
}