MFRC 522 and HC SR04 Compatability

Greetings !

Hope everybody is doing well.

I have a problem regarding the working of the hc sr04 ultrasonic sensor.

I used an Arduino Mega for this project. I have attached the circuit diagram below as well as the program.

Summary of the project:

The program is such that if a Card is scanned by the rfid reader and the card is authorized, the user has to place his hands in front of the sensor. The sensor shall detect the presence of the hand and make three leds glow one by one (traffic lights). If the Card is not allowed, the user will not be allowed to continue.

Problem:

The problem I am facing right now is that the once the I scan my authorized card with the rfid reader and move to the sensor stage, the sensor does not seem to work.

Inference:

The sensor works very well when the rfid is removed.

I would be much grateful for any help, insight or guidance.

Regards and Best Wishes
Bob

AutoSani_1.ino (2.5 KB)