Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Nauras Shaji
Created August 27, 2024

TactiFind

Object Locator for the Visually Impaired.

12
TactiFind

Things used in this project

Story

Read more

Code

TactiFind

Arduino
its an arduino code run it using arduino ide
#include <SPI.h>
#include <MFRC522.h>

// Define pins (change these as necessary for your setup)
#define SS_PIN    10    // SDA (SS) pin
#define RST_PIN   9     // RST pin
#define BUZZER_PIN 8    // Pin connected to buzzer or speaker

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

String lastLocation = "Unknown";  // Variable to store last known location

void setup() {
    Serial.begin(115200);   // Initialize serial communications
    SPI.begin();            // Init SPI bus
    mfrc522.PCD_Init();     // Init MFRC522
    
    pinMode(BUZZER_PIN, OUTPUT); // Set buzzer pin as output
    
    Serial.println("RFID Walking Stick Localization System Initialized.");
}

void loop() {
    // Check if a new card is present
    if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
        String currentID = "";
        for (byte i = 0; i < mfrc522.uid.size; i++) {
            currentID += String(mfrc522.uid.uidByte[i], HEX);  // Create a unique ID from RFID tag
        }

        // Convert to uppercase to ensure consistent comparison
        currentID.toUpperCase();

        // Detect the location based on the RFID tag's ID
        if (currentID == "FD60F949") {  // Replace with the unique ID of the tag in the living room
            lastLocation = "Living Room";
            provideFeedback("Living Room");
        }
        else if (currentID == "322F3621") {  // Replace with the unique ID of the tag in the workplace
            lastLocation = "Workplace";
            provideFeedback("Workplace");
        }
        else {
            lastLocation = "Unknown Location";
            provideFeedback("Unknown Location");
        }

        mfrc522.PICC_HaltA();  // Halt PICC
        mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD
    }
}

void provideFeedback(String location) {
    Serial.print("Walking Stick Last Detected at: ");
    Serial.println(location);

    if (location == "Living Room") {
        // Beep to indicate the location
        tone(BUZZER_PIN, 1000); // Turn on buzzer with 1 kHz tone
        delay(500);             // Delay for 500 ms
        noTone(BUZZER_PIN);     // Turn off buzzer
        delay(1000);            // Delay for 1 second
        tone(BUZZER_PIN, 1000); // Turn on buzzer with 1 kHz tone
        delay(500);             // Delay for 500 ms
        noTone(BUZZER_PIN);     // Turn off buzzer
    }
    else if (location == "Workplace") {
        // Different beep to indicate the location
        tone(BUZZER_PIN, 1000); // Turn on buzzer with 1 kHz tone
        delay(500);             // Delay for 500 ms
        noTone(BUZZER_PIN);     // Turn off buzzer
        delay(1000);            // Delay for 1 second
        tone(BUZZER_PIN, 1000); // Turn on buzzer with 1 kHz tone
        delay(500);             // Delay for 500 ms
        noTone(BUZZER_PIN);     // Turn off buzzer
    }
    else {
        // Beep to indicate unknown location
        tone(BUZZER_PIN, 1000); // Turn on buzzer with 1 kHz tone
        delay(500);             // Delay for 500 ms
        noTone(BUZZER_PIN);     // Turn off buzzer
    }
}

Credits

Nauras Shaji

Nauras Shaji

1 project • 2 followers

Comments