RFID Desk Lamp with RGB Color Scheme Lock

Enhance a dilapidated desk lamp w/ insipid features into an RFID enabled one w/ personalized RGB color scheme lock via Arduino.

Similar projects worth following
I have had a dilapidated desk lamp for a long time, which waits in a box due to its outdated design with insipid features. Hence, I decided to improve my old lamp as my new desk lamp for my home office with new intriguing features. Despite the fact that it had no room for adding new parts in its base, I designed a PCB to put all components on the top of it. And, oddly enough, this design gave a steampunk-esque vibe to the lamp :)

To enhance my old lamp by superseding tasteless features, I decided to add a personalized lock removed by an RFID key merely to turn on the light. And, to set the lock again, I wanted to use a specialized color scheme. Thus, for enabling RFID to turn on the lamp, I used an Arduino Nano, an MFRC522 RFID Module, and a 2-Way Relay. But, I would still need to create a locking pattern entry system for my project, so I used three potentiometers (with knobs) to adjust the color pattern and an RGB to show it.

After completing my project, I designed the mentioned PCB with the unique triangular shape complementary to the lamp.

Huge thanks to JLCPCB for sponsoring this project.

Step 1: Designing and Soldering the RFID Desk Lamp v2.0 PCB

I designed the RFID Desk Lamp v2.0 PCB by using KiCad. I attached the Gerber file of the PCB below, so if you want, you can order this PCB from JLCPCB to renew your older lamps as I did :)

First of all, by using a soldering iron, I attached headers, resistors, the power jack, RGB, 5mm green LED, and potentiometers.

Component list on the PCB:

Nano (Headers for Arduino Nano)

RFID (Headers for MFRC522 RFID Module)

Relay (Headers for 2-Way Relay)


LED (5mm Green LED)

J5 (Power Jack)

R1, R2, R3, R4 (220Ω Resistors)

RV1 (Red Pot.)

RV2 (Blue Pot.)

RV3 (Green Pot.)

Even though there are no SMD components on the board, if you want, you can order a stencil to apply solder paste to the holes as I did, especially for soldering a headerless Arduino Nano.

Step 2: Registering and Reading UIDs with the MFRC522 RFID Module

Download the required library for the MFRC522 RFID Module from here.

Not surprisingly, it is simple to register and read UIDs with the MFRC522 RFID Module: approximate the RFID card or key to the module and run the code for reading or registering.

To save a new UID to the EEPROM, uncomment the registerCardUID() function and run the code:

int registerCardUID() {  // Detect the new card UID.   if ( ! mfrc522.PICC_IsNewCardPresent()) {     return 0;  }  if ( ! mfrc522.PICC_ReadCardSerial()) {    return 0;  }
  // Display the new UID.  Serial.print("\n----------------------------------\nNew Card or Key Tag UID : ");  for (int i = 0; i < mfrc522.uid.size; i++) {  //    readCard[i] = mfrc522.uid.uidByte[i];    Serial.print(readCard[i], HEX);  }  Serial.print("\n----------------------------------\n");    // Save the new UID to EEPROM.   for ( int i = 0; i < mfrc522.uid.size; i++ ){   EEPROM.write(i, readCard[i] );  }  Serial.print("UID is saved successfully to the EEPROM.\n");    // If the card registering process is successful, return 1 and end the reading process.  mfrc522.PICC_HaltA();  return 1;

To get the saved UID in the EEPROM, run this code:

int get_saved_UID(){  // Get the saved UID in the EEPROM.  for(int i=0;i<4;i++){    savedUID += < 0x10 ? " 0" : " ";    savedUID += String(, HEX);    }  // Arrange the savedUID for comparison.  savedUID.trim();  savedUID.toUpperCase();

To compare the saved UID in the EEPROM and the currently read UID by the RFID module, execute this code:

int UID(){  // Get the last UID from MFRC522.  if ( ! mfrc522.PICC_IsNewCardPresent()){    return;  }  if ( ! mfrc522.PICC_ReadCardSerial()){    return;  }  for(int i=0;i<mfrc522.uid.size;i++){    lastRead += mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ";    lastRead += String(mfrc522.uid.uidByte[i], HEX);  }    // Arrange the lastRead for comparison.  lastRead.trim();  lastRead.toUpperCase();
    // Remove the LOCK if the UID is accurate.  if(lastRead == savedUID){    LOCK = false;    while(LOCK == false){      // Get potentiometer data from 0 to 255.      readPotentiometer();      // Adjust RGB led colors in regard to potentiometer values.      adjustColor(red, green, blue);      // Turn relay and controlLed on.      digitalWrite(controlLed, HIGH);      digitalWrite(IN_1, LOW);      // Set the LOCK.      if(red == 0 && green == 0 && blue == 0){        LOCK = true;        // Blank the lastRead.        lastRead = "";        }      }    }

For more detailed information about the code, please go to the following step.

Step 3: Programming the Arduino Nano

  • Include the required libraries.
  • Create the MFRC522 instance.
  • Define the MFRC522 module key input.
  • Define the readCard byte array storing the scanned ID read by RFID Module.
  • Define the data holders.
  • Define the LOCK boolean to either set or remove the LOCK.
  • Define RGB pins, the controlLed pin, and potentiometer pins.
  • Initialize MFRC522 Hardware.
  • If you have not registered a UID to the EEPROM yet, upload the code after turning the emphasized...
Read more »

x-zip-compressed - 135.85 kB - 08/12/2020 at 13:42


  • 1 × Arduino Nano R3
  • 1 × MFRC522 RFID Module
  • 1 × 2-Way Relay
  • 1 × RFID Key or Card
  • 3 × Rotary potentiometer

View all 10 components

  • 1
  • 2
  • 3

View all 3 instructions

Enjoy this project?



kutluhan_aktar wrote 08/12/2020 at 13:48 point

Please leave a comment here if you have any questions or concerns regarding this project :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates