@@archiehaigh4796 I didn't forget about ya. Before I answer I want to test it out first so I'm not posting confusion :) I will try it out this evening and let you know.
I added a video and code for 2 ID cards on the Facebook page. I declared my second tag ID as "String tagUID2" and set up a 2nd if/else statement in the loop for the 2nd tag. See the post and let me know what ya think.
Hello BMonster Lab. First of all I enjoy watching your tutorials 😁 I learned a lot about electronics in a short time span. Can you do one favor. could u please upload the schematics for this particular project. Thank you.
Hi Joe! Great to hear! I just posted the video and code on my Facebook page. For some reason I can't post code in the comment section here. facebook.com/BMonster-Laboratory-101410418059806/
hello! I'm planning to use a servo-operated lock for a project of mine, and was wondering is you still had a link to that specific lock? It's nice that a wire can be fed into the handle. I think I found it but so far nothing has given me a side-view to verify it's hollow. Thanks a lot!
I can't figure out how to add multiple tags. I tried adding a comma like you said but then neither of my tags work. Right now, I can use only one tag. Thanks!
hi! You can use an array of strings to store the allowed UIDs and then check if the scanned tag's UID matches any of the allowed UIDs. Try this. The sketch for this video was posted to Facebook. After modifying it, it would look like this. #include #include #include MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN) Servo myservo; int angle = 0; // Array to store UIDs of allowed tags. Change these values to your tag UIDs. String allowedTags[] = {"F9 8A D2 A3", "YOUR_SECOND_TAG_UID", "YOUR_THIRD_TAG_UID"}; int numAllowedTags = sizeof(allowedTags) / sizeof(allowedTags[0]); int redLEDPin = 8; int greenLEDPin = 9; void setup() { myservo.attach(3); SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 pinMode(redLEDPin, OUTPUT); //LED startup sequence pinMode(greenLEDPin, OUTPUT); digitalWrite(redLEDPin, HIGH); delay(200); digitalWrite(greenLEDPin, HIGH); delay(200); digitalWrite(redLEDPin, LOW); delay(200); digitalWrite(greenLEDPin, LOW); Serial.begin(9600); // Initialize serial communications } void loop() { // Look for new cards if (!mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if (!mfrc522.PICC_ReadCardSerial()) { return; } // Reading from the card String tag = ""; for (byte i = 0; i < mfrc522.uid.size; i++) { tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); tag.concat(String(mfrc522.uid.uidByte[i], HEX)); } tag.toUpperCase(); // Check if the scanned tag is in the list of allowed tags bool accessGranted = false; for (int i = 0; i < numAllowedTags; i++) { if (tag.substring(1) == allowedTags[i]) { accessGranted = true; break; } } if (accessGranted) { // If the tag is allowed Serial.println("Access Granted"); digitalWrite(greenLEDPin, HIGH); // Green LED sequence delay(200); digitalWrite(greenLEDPin, LOW); delay(200); digitalWrite(greenLEDPin, HIGH); delay(200); digitalWrite(greenLEDPin, LOW); delay(200); myservo.write(180); delay(5000); myservo.write(0); } else { // If the tag is not allowed Serial.println("Access Denied"); digitalWrite(redLEDPin, HIGH); // Red LED sequence delay(200); digitalWrite(redLEDPin, LOW); delay(200); digitalWrite(redLEDPin,
Hello thanks for explaining, I'm going to program a gaz sensor for my final project the gaz sensor+ buzzer + led it's working for me but i don't know how to program with it a servomotor is there any code for all these please, or can i have help I'm not good in programmation
hi there! I'm not sure what a gaz sensor is. Is this a gas sensor? Like a CO2 or methane sensor with a buzzer and led flashing lights? What is the purpose of the servo motor in your setup? It sounds like a great project...just need more detail. I would be happy to help however I can. Thanks for asking!
Yeah it's a gaz sensor for all gaz toxic , the servo motor should be turning the gaz off when the gaz is on , i just tried to modify my code with how u programs the servo motor it's working but not following the gaz , i hope u can help me cuz i have a close deadline It's a methane sensor with a buzzer and led flashing lights
Hi ! is there a way to not use the LEDs and also just use the default rfid card and tag given , while letting the code work ? because i have been trying and editing it doesnt work out.
Hi there! yes, you can switch from mega to uno in the IDE. click the tools tab on the top left, click on the "board" drop down menu, click Arduino AVR Boards and select "UNO" from the drop down menu. Also, make sure you have the right port selected under the tools tab. Hope that helps! This video may help with getting started - ua-cam.com/video/UiQ7bEZdvOg/v-deo.html
hi, I was just wondering is there any way of editing the code so that if you hold the rfid card on the sensor for 5 seconds, it leaves the servo motor in the unlocked position. This would be really helpful as the lock is going on a room that people go in so I would need to leave the door unlocked at times so that they can get in? Thanks so much.
Sure, this can be done. I will have to play around with the code...I'm not a c++ expert yet :) I'm traveling ast the moment but will work on this later today.
Hello I am having an issue with the part about the serial monitor. I am not quite sure why. I checked both my pins and they were correct but nothing popped up in the serial monitor. Any suggestions?
Hi Ryan. make sure your setup baud speed matches the baud on your serial monitor. if you use "Serial.begin(9600);" in setup, set it to 9600 on the monitor in the drop down tab. hope that helps!
Yes, you can. Here is an example of how to control a servo motor using IR. learn.adafruit.com/using-an-infrared-library/controlling-a-servo-with-ir-1 I can help if you need anymore instruction. good luck to you~
If you look at the adafruit code - you can copy the IR portion out of the code example. You can alter it to fit your project. That would be the easiest way to get it done. Also, you might want a stronger IR signal than the one they give you in the Elegoo Mega kit.
Hi there! That metal piece is from a toy that I took apart. It was attached to a servo in a robot toy. I have also used a large paper clip and bent it to have the same "L" angle so it doesn't slip out of the servo arm. Try the paper clip - it actually works well!
@@BMonsterLaboratory thanks I have another question if you can help I have a rotating door lock unlike this one I tried just taping the servo motor horn to it It managed to turn it around but when it came to locking it didn't have enough power (I have the micro servo 9g) Do you think having a 10kg.cm servo will work?
It may just be an issue of repositioning your servo to get an angle it can use to rotate the lock closed. You may want to experiment with different ways to get the servo to open and close the lock. For instance, you may have to put your servo under the lock rather than to the side. You may be better off using some kind of flexible wire or string rather than a paper clip. Perhaps there’s a way to extend the arm of your servo so it can move the lock easier…maybe explore that idea. The 9g servo is not all that strong (about 2.5kg-cm) so a bigger servo may help in your situation. Sometimes deadbolt locks have some wiggle room and they don’t go though a strike plate easily. Perhaps you could manually check the lock and how easy it operates. It’s hard to say if a 10kg-cm is necessary but then again it may get the job done pretty well. I like the idea of a larger servo anyway. It if works better, great! Otherwise, you have a nice strong servo or 2 for another project! Sorry I don’t have a better answer for ya
For the breadboard, it's just 2 leds. The ground rail is connected to Arduino ground pin. Both short pins of the leds are connected to that same ground rail. The long pin of the 2 leds are each connected to a 220ohm resistor which is connected to pin 8 and 9 on the Arduino. That's it. Hope that helps 👍
If your closed angle is 0, close the lock and reattach the servo. the servo will go to 180 when the lock is open. You may also need to disconnect your servo power and rotate arm to 0 (locked) position. Be sure it's disconnected and don't use excessive force or attempt to move the arm beyond its normal range of motion. I think that should do it! Have fun 👊👍
hello! I found the code on the Facebook post and removed the LED functionality. Here it is. #include #include #include MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN) Servo myservo; int angle=0; String tagUID = "F9 8A D2 A3"; // String to store UID of tag. Change it with your tag's UID void setup() { myservo.attach(3); SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 } void loop() { // Look for new cards if (!mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if (!mfrc522.PICC_ReadCardSerial()) { return; } //Reading from the card String tag = ""; for (byte i = 0; i < mfrc522.uid.size; i++) { tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); tag.concat(String(mfrc522.uid.uidByte[i], HEX)); } tag.toUpperCase(); //Checking the card if (tag.substring(1) == tagUID) //change here the UID of the card/cards that you want to give access { myservo.write(180); delay(5000); myservo.write(0); } else { // If UID of tag is not matched. Serial.println ("Access Denied"); } }
Hey Rich! This happens to me when I don't have sufficient power to the servo. Are you using an external 5-6v power supply? Is your lock too heavy or is if difficult to lock and unlock?
@@BMonsterLaboratory I haven't attached a lock yet. I will try using my bench power supply. I've had it setup on a breadboard. I will set it up again later and will let you know how it goes.
int is a data-type. lock is defined pin 4 on the Arduino board. Check out Arduino reference page and cplusplus.com tutorials for references. It's very helpful.
the 220ohm resistor is between pin 8 and 9 and the positive leg of the LED. the negative leg of the LED goes straight to the ground rail. So, pin 8 and 9 of the Elegoo board to the resistor then to the positive side of the LED. You just want to control current through the LED so it doesn't burn out - therefore, we put a resistor between the led and the pin on our microcontroller.
I posted the code in the comments here. In the past it would change the format. Let me know if that works...I can always send it by email. Good luck to ya, Archie! Take care~👍
Hi Gino! The red wire is connected to pin 9 on the mega board. The red wire is connected to a 220ohm resistor which is connected to the positive side of the green led. The ground (-) side of the green led is connected to the ground rail of the breadboard. The red led is connected the same way except it's at pin 8. Hope that helps!
@@ginoantenucci6424 all the wires connected to the breadboard from the Mega board are male to male. the wires connecting the red an green leds are male to male.
Arduino: 1.8.19 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)" dump:3:10: fatal error: MFRC522.h: No such file or directory #include ^~~~~~~~~~~ compilation terminated. exit status 1 MFRC522.h: No such file or directory This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
Hi Soapzyy! In Arduino IDE: Go to tools - manage libraries - search "MFRC522"- download - go to sketch - include library - add .zip library - and select the MFRC522 file you just downloaded. be sure to include #include #include in your code, just as you see here. That should get you set up. I posted the code on out Facebook page - search #SimpleKeylessDoorLock Code was way too long to post on UA-cam.
here it is #include #include #include MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN) Servo myservo; int angle=0; String tagUID = "F9 8A D2 A3"; // String to store UID of tag. Change it with your tag's UID int redLEDPin = 8; int greenLEDPin = 9; void setup() { myservo.attach(3); SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 pinMode(redLEDPin, OUTPUT); //LED startup sequence pinMode(greenLEDPin, OUTPUT); digitalWrite(redLEDPin, HIGH); delay(200); digitalWrite(greenLEDPin, HIGH); delay(200); digitalWrite(redLEDPin, LOW); delay(200); digitalWrite(greenLEDPin, LOW); } void loop() { // Look for new cards if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) { return; } //Reading from the card String tag = ""; for (byte i = 0; i < mfrc522.uid.size; i++) { tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); tag.concat(String(mfrc522.uid.uidByte[i], HEX)); } tag.toUpperCase(); //Checking the card if (tag.substring(1) == tagUID) //change here the UID of the card/cards that you want to give access { digitalWrite(greenLEDPin, HIGH); //Green LED sequence delay(200); digitalWrite(greenLEDPin, LOW); delay(200); digitalWrite(greenLEDPin, HIGH); delay(200); digitalWrite(greenLEDPin, LOW); delay(200); myservo.write(180); //digitalWrite(greenLed, HIGH); delay(5000); //digitalWrite(greenLed, LOW); myservo.write(0); } else { // If UID of tag is not matched. Serial.println ("Access Denied"); digitalWrite(redLEDPin, HIGH); //Red LED sequence delay(200); digitalWrite(redLEDPin, LOW); delay(200); digitalWrite(redLEDPin, HIGH); delay(200); digitalWrite(redLEDPin, LOW); delay(200); } }
@@BMonsterLaboratory I am totally newbie can I ask you ‘’if I want to hold the servo in 35 degrees when the card place and release to 0 when card is remove’’ what do I type in?
@Nyan Tun my initial thought would be to use a While loop. If the condition is true in a while loop (holding your card to the scanner) the loop will execute. The loop will continue until false (you remove your card from the scanner) - the loop will terminate. It may take me some time to set my project back up to test it out but this should point you in the right direction I believe.
bro can u help me now !!! im cant use code MFRC522.h Arduino: 1.8.18 (Windows 10), Board: "Arduino Uno" Arduino-Security-Access-Lock-RFID-MFRC522:7:10: fatal error: MFRC522.h: No such file or directory #include ^~~~~~~~~~~ compilation terminated. exit status 1 MFRC522.h: No such file or directory This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. pls help me!!
The code could probably be cleaned up a bit but overall, this was a fun project. Give it a try! Thanks for watching~
Hi BMonster, is there any way of adding more than one rfid card to the code? Thanks.
@@archiehaigh4796 I didn't forget about ya. Before I answer I want to test it out first so I'm not posting confusion :) I will try it out this evening and let you know.
I added a video and code for 2 ID cards on the Facebook page. I declared my second tag ID as "String tagUID2" and set up a 2nd if/else statement in the loop for the 2nd tag. See the post and let me know what ya think.
@@BMonsterLaboratory thank you, is there any way you can send the updated code by email as I don’t have Facebook. Thank you.
@@archiehaigh4796 i'm emailing it to you now
excellent video this helped me a lot, thanks 😁
Carlitos, that's awesome! I hope you enjoy future Arduino videos. Thank you for this message. Take care! 👊
Hello BMonster Lab.
First of all I enjoy watching your tutorials 😁 I learned a lot about electronics in a short time span. Can you do one favor. could u please upload the schematics for this particular project.
Thank you.
Hi Joe! Great to hear! I just posted the video and code on my Facebook page. For some reason I can't post code in the comment section here.
facebook.com/BMonster-Laboratory-101410418059806/
Also very good toutorial
Jonas, thank you for the kind comment.
hello! I'm planning to use a servo-operated lock for a project of mine, and was wondering is you still had a link to that specific lock? It's nice that a wire can be fed into the handle. I think I found it but so far nothing has given me a side-view to verify it's hollow. Thanks a lot!
Hi there! I got this on Amazon. Do a search with ASIN:B07SHS9TQH that should pull it up
Possible to verify payment before unlocking.great for vending machine as well as Airbnb.thx
awesome! 👍
I can't figure out how to add multiple tags. I tried adding a comma like you said but then neither of my tags work. Right now, I can use only one tag. Thanks!
hi! You can use an array of strings to store the allowed UIDs and then check if the scanned tag's UID matches any of the allowed UIDs. Try this. The sketch for this video was posted to Facebook. After modifying it, it would look like this.
#include
#include
#include
MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN)
Servo myservo;
int angle = 0;
// Array to store UIDs of allowed tags. Change these values to your tag UIDs.
String allowedTags[] = {"F9 8A D2 A3", "YOUR_SECOND_TAG_UID", "YOUR_THIRD_TAG_UID"};
int numAllowedTags = sizeof(allowedTags) / sizeof(allowedTags[0]);
int redLEDPin = 8;
int greenLEDPin = 9;
void setup() {
myservo.attach(3);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
pinMode(redLEDPin, OUTPUT); //LED startup sequence
pinMode(greenLEDPin, OUTPUT);
digitalWrite(redLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, LOW);
Serial.begin(9600); // Initialize serial communications
}
void loop() {
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
// Reading from the card
String tag = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
tag.concat(String(mfrc522.uid.uidByte[i], HEX));
}
tag.toUpperCase();
// Check if the scanned tag is in the list of allowed tags
bool accessGranted = false;
for (int i = 0; i < numAllowedTags; i++) {
if (tag.substring(1) == allowedTags[i]) {
accessGranted = true;
break;
}
}
if (accessGranted) {
// If the tag is allowed
Serial.println("Access Granted");
digitalWrite(greenLEDPin, HIGH); // Green LED sequence
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
myservo.write(180);
delay(5000);
myservo.write(0);
} else {
// If the tag is not allowed
Serial.println("Access Denied");
digitalWrite(redLEDPin, HIGH); // Red LED sequence
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(redLEDPin,
You are scanning each card for it's own unique UID ? just checkin' 👍
good video but it keeps on giving me an error "wARNING: Communication failure, is the MFRC522 properly connected?
Hey there! Do you have the correct Arduino board and COM port selected in IDE? Hopefully that's all it is.
Hello thanks for explaining, I'm going to program a gaz sensor for my final project the gaz sensor+ buzzer + led it's working for me but i don't know how to program with it a servomotor is there any code for all these please, or can i have help I'm not good in programmation
hi there! I'm not sure what a gaz sensor is. Is this a gas sensor? Like a CO2 or methane sensor with a buzzer and led flashing lights? What is the purpose of the servo motor in your setup? It sounds like a great project...just need more detail. I would be happy to help however I can. Thanks for asking!
Yeah it's a gaz sensor for all gaz toxic , the servo motor should be turning the gaz off when the gaz is on , i just tried to modify my code with how u programs the servo motor it's working but not following the gaz , i hope u can help me cuz i have a close deadline
It's a methane sensor with a buzzer and led flashing lights
If it's possible i can send u more on Instagram or Whatsapp or any app u have , thank you
Hi thank you for the Amazing video, can you tell me where I can find that code
@Bmonster lab
hi there! I posted it on Facebook under #SimpleKeylessDoorLock it's too large to post in the description. Thanks for the kind comment! 👍
most recent code is posted to Facebook because it doesn't fit on UA-cam. I an email it if you don't have Facebook.
Hi ! is there a way to not use the LEDs and also just use the default rfid card and tag given , while letting the code work ? because i have been trying and editing it doesnt work out.
I just replied to your email. I hope it was helpful. If you still have questions, feel free to ask
Hello BMonster Laboratory, Can i change Arduino mega 2560 to arduino uno r3?
Hi there! yes, you can switch from mega to uno in the IDE. click the tools tab on the top left, click on the "board" drop down menu, click Arduino AVR Boards and select "UNO" from the drop down menu. Also, make sure you have the right port selected under the tools tab. Hope that helps! This video may help with getting started - ua-cam.com/video/UiQ7bEZdvOg/v-deo.html
hi, I was just wondering is there any way of editing the code so that if you hold the rfid card on the sensor for 5 seconds, it leaves the servo motor in the unlocked position. This would be really helpful as the lock is going on a room that people go in so I would need to leave the door unlocked at times so that they can get in? Thanks so much.
Sure, this can be done. I will have to play around with the code...I'm not a c++ expert yet :)
I'm traveling ast the moment but will work on this later today.
@@BMonsterLaboratory thank you so much.
@@archiehaigh4796 I just emailed the code to you. I think I may add a video using the code I just sent you. Let me know how it goes! good luck
Hello I am having an issue with the part about the serial monitor. I am not quite sure why. I checked both my pins and they were correct but nothing popped up in the serial monitor. Any suggestions?
Hi Ryan. make sure your setup baud speed matches the baud on your serial monitor. if you use "Serial.begin(9600);" in setup, set it to 9600 on the monitor in the drop down tab. hope that helps!
Can i somehow also add an ir remote to unlock the door without standing up?
Yes, you can. Here is an example of how to control a servo motor using IR. learn.adafruit.com/using-an-infrared-library/controlling-a-servo-with-ir-1 I can help if you need anymore instruction. good luck to you~
If you look at the adafruit code - you can copy the IR portion out of the code example. You can alter it to fit your project. That would be the easiest way to get it done. Also, you might want a stronger IR signal than the one they give you in the Elegoo Mega kit.
Can you tell me what is the thing connecting the servo with the lock
Can I use a paper clip?
Hi there! That metal piece is from a toy that I took apart. It was attached to a servo in a robot toy. I have also used a large paper clip and bent it to have the same "L" angle so it doesn't slip out of the servo arm. Try the paper clip - it actually works well!
@@BMonsterLaboratory thanks
I have another question if you can help
I have a rotating door lock unlike this one
I tried just taping the servo motor horn to it
It managed to turn it around but when it came to locking it didn't have enough power (I have the micro servo 9g)
Do you think having a 10kg.cm servo will work?
The one I'm using is around 1.3 or 1.8 kg.cm
It may just be an issue of repositioning your servo to get an angle it can use to rotate the lock closed. You may want to experiment with different ways to get the servo to open and close the lock. For instance, you may have to put your servo under the lock rather than to the side. You may be better off using some kind of flexible wire or string rather than a paper clip. Perhaps there’s a way to extend the arm of your servo so it can move the lock easier…maybe explore that idea. The 9g servo is not all that strong (about 2.5kg-cm) so a bigger servo may help in your situation.
Sometimes deadbolt locks have some wiggle room and they don’t go though a strike plate easily. Perhaps you could manually check the lock and how easy it operates. It’s hard to say if a 10kg-cm is necessary but then again it may get the job done pretty well. I like the idea of a larger servo anyway. It if works better, great! Otherwise, you have a nice strong servo or 2 for another project! Sorry I don’t have a better answer for ya
@@BMonsterLaboratory it's fine the answer is more than good enough
Really appreciate your help
Wish you a good day
Hii there!
Can you please provide the breadboard schematics?
For the breadboard, it's just 2 leds. The ground rail is connected to Arduino ground pin. Both short pins of the leds are connected to that same ground rail.
The long pin of the 2 leds are each connected to a 220ohm resistor which is connected to pin 8 and 9 on the Arduino. That's it. Hope that helps 👍
when i want to open it manually the servo will resist and i can't get new position (opened) any idea how to solve this ?
If your closed angle is 0, close the lock and reattach the servo. the servo will go to 180 when the lock is open. You may also need to disconnect your servo power and rotate arm to 0 (locked) position. Be sure it's disconnected and don't use excessive force or attempt to move the arm beyond its normal range of motion. I think that should do it! Have fun 👊👍
@@BMonsterLaboratory I'm going to try this, thank you so much very clear and informative video👏
@@ghoumamohamed you're welcome. best of luck on your projects.
Can you please give me the whole code except for the LED part? Thx in advance
hello! I found the code on the Facebook post and removed the LED functionality. Here it is.
#include
#include
#include
MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN)
Servo myservo;
int angle=0;
String tagUID = "F9 8A D2 A3"; // String to store UID of tag. Change it with your tag's UID
void setup() {
myservo.attach(3);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
}
void loop() {
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
//Reading from the card
String tag = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
tag.concat(String(mfrc522.uid.uidByte[i], HEX));
}
tag.toUpperCase();
//Checking the card
if (tag.substring(1) == tagUID) //change here the UID of the card/cards that you want to give access
{
myservo.write(180);
delay(5000);
myservo.write(0);
}
else
{
// If UID of tag is not matched.
Serial.println ("Access Denied");
}
}
@@BMonsterLaboratory thanks so much(going to sub and tell my friend about this channel)
@@Lowgraphic0 Awesome. thanks~!
It tells communication failure and i cant find why can you help me please
Do you have the correct board and port selected under the tools drop down menu in IDE?
My servo keeps buzzing in locked and unlocked positions. Like it's trying to move further.
Hey Rich! This happens to me when I don't have sufficient power to the servo. Are you using an external 5-6v power supply? Is your lock too heavy or is if difficult to lock and unlock?
@@BMonsterLaboratory I haven't attached a lock yet. I will try using my bench power supply. I've had it setup on a breadboard. I will set it up again later and will let you know how it goes.
@@Richie_ sounds good. Just don't power motors from arduino. Use a breadboard power supply.
@@BMonsterLaboratory it seems ok now. What is the code int lock = 4; do? what is the value 4?
int is a data-type. lock is defined pin 4 on the Arduino board. Check out Arduino reference page and cplusplus.com tutorials for references. It's very helpful.
Where does the 220 ohm resisters go?
the 220ohm resistor is between pin 8 and 9 and the positive leg of the LED. the negative leg of the LED goes straight to the ground rail. So, pin 8 and 9 of the Elegoo board to the resistor then to the positive side of the LED. You just want to control current through the LED so it doesn't burn out - therefore, we put a resistor between the led and the pin on our microcontroller.
If you're just starting out, it can be tricky.
Hi, I am not on Facebook, is there any other way that you can send the code to me so that I can make this project?
#include
#include
#include
MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN)
Servo myservo;
int angle=0;
String tagUID = "F9 8A D2 A3"; // String to store UID of tag. Change it with your tag's UID
int redLEDPin = 8;
int greenLEDPin = 9;
void setup() {
myservo.attach(3);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
pinMode(redLEDPin, OUTPUT); //LED startup sequence
pinMode(greenLEDPin, OUTPUT);
digitalWrite(redLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, LOW);
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
//Reading from the card
String tag = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
tag.concat(String(mfrc522.uid.uidByte[i], HEX));
}
tag.toUpperCase();
//Checking the card
if (tag.substring(1) == tagUID) //change here the UID of the card/cards that you want to give access
{
digitalWrite(greenLEDPin, HIGH); //Green LED sequence
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
myservo.write(180);
//digitalWrite(greenLed, HIGH);
delay(5000);
//digitalWrite(greenLed, LOW);
myservo.write(0);
}
else
{
// If UID of tag is not matched.
Serial.println ("Access Denied");
digitalWrite(redLEDPin, HIGH); //Red LED sequence
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(redLEDPin, HIGH);
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
}
}
I posted the code in the comments here. In the past it would change the format. Let me know if that works...I can always send it by email. Good luck to ya, Archie! Take care~👍
By the way, I plan on posting some other options using this lock and servo setup. Hope you'll check that out as well.
@@BMonsterLaboratory hi, the code changed format, pls could you send the code file to me by email. Thanks
@@archiehaigh4796 email bmonsterlaboratory@gmail.com and I'll send in a reply. Also make sure you have the 3 libraries installed
Please help on 9:15 i cant find where does pins go
Hi Gino! The red wire is connected to pin 9 on the mega board. The red wire is connected to a 220ohm resistor which is connected to the positive side of the green led. The ground (-) side of the green led is connected to the ground rail of the breadboard. The red led is connected the same way except it's at pin 8. Hope that helps!
@@BMonsterLaboratory is it jumper or female to male wires
@@ginoantenucci6424 all the wires connected to the breadboard from the Mega board are male to male. the wires connecting the red an green leds are male to male.
@@BMonsterLaboratory thx so much
@@ginoantenucci6424 You're welcome. Glad to help out
it says no such file in directory what do i do?
Arduino: 1.8.19 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
dump:3:10: fatal error: MFRC522.h: No such file or directory
#include
^~~~~~~~~~~
compilation terminated.
exit status 1
MFRC522.h: No such file or directory
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Hi Soapzyy! In Arduino IDE: Go to tools - manage libraries - search "MFRC522"- download -
go to sketch - include library - add .zip library - and select the MFRC522 file you just downloaded.
be sure to include
#include
#include
in your code, just as you see here. That should get you set up.
I posted the code on out Facebook page - search #SimpleKeylessDoorLock
Code was way too long to post on UA-cam.
see my previous reply. hope it helps!
Hey I was wondering if you could email the code to me because it will be faster. Thanks!
Hey! Ya, sure. Send me email at bmonsterlaboratory@gmail.com I'm happy to send it 👍
I can't get the code.
Hi Gage! Go to facebook and do a search for #SimpleKeylessDoorLock - you'll see it in the video description. Let me know if you still have trouble.
Please give me the code
Circuit diagram please
here it is
#include
#include
#include
MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN)
Servo myservo;
int angle=0;
String tagUID = "F9 8A D2 A3"; // String to store UID of tag. Change it with your tag's UID
int redLEDPin = 8;
int greenLEDPin = 9;
void setup() {
myservo.attach(3);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
pinMode(redLEDPin, OUTPUT); //LED startup sequence
pinMode(greenLEDPin, OUTPUT);
digitalWrite(redLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, LOW);
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
//Reading from the card
String tag = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
tag.concat(String(mfrc522.uid.uidByte[i], HEX));
}
tag.toUpperCase();
//Checking the card
if (tag.substring(1) == tagUID) //change here the UID of the card/cards that you want to give access
{
digitalWrite(greenLEDPin, HIGH); //Green LED sequence
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
myservo.write(180);
//digitalWrite(greenLed, HIGH);
delay(5000);
//digitalWrite(greenLed, LOW);
myservo.write(0);
}
else
{
// If UID of tag is not matched.
Serial.println ("Access Denied");
digitalWrite(redLEDPin, HIGH); //Red LED sequence
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(redLEDPin, HIGH);
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
}
}
see 8:01 for rfid reader wiring. 👍
Can I get a code
Hi Nyan. Check the facebook page (link is on the banner). It should be listed under the video post. Let me know if you can't find it.
@@BMonsterLaboratory I am totally newbie can I ask you ‘’if I want to hold the servo in 35 degrees when the card place and release to 0 when card is remove’’ what do I type in?
@Nyan Tun my initial thought would be to use a While loop. If the condition is true in a while loop (holding your card to the scanner) the loop will execute. The loop will continue until false (you remove your card from the scanner) - the loop will terminate. It may take me some time to set my project back up to test it out but this should point you in the right direction I believe.
bro can u help me now !!! im cant use code MFRC522.h
Arduino: 1.8.18 (Windows 10), Board: "Arduino Uno"
Arduino-Security-Access-Lock-RFID-MFRC522:7:10: fatal error: MFRC522.h: No such file or directory
#include
^~~~~~~~~~~
compilation terminated.
exit status 1
MFRC522.h: No such file or directory
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
pls help me!!
Hi there.
You need to install the MFRC522 library. Go to "manage libraries" in your IDE and search "MFRC522". Install it from there.
@@BMonsterLaboratory thanks bro 👍🏽👍🏽 appreciate you
Hey BMonster could you please email me the code for the project. Thanks!
#include
#include
#include
MFRC522 mfrc522(53, 5); // MFRC522 mfrc522(SS_PIN, RST_PIN)
Servo myservo;
int angle=0;
String tagUID = "F9 8A D2 A3"; // String to store UID of tag. Change it with your tag's UID
int redLEDPin = 8;
int greenLEDPin = 9;
void setup() {
myservo.attach(3);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
pinMode(redLEDPin, OUTPUT); //LED startup sequence
pinMode(greenLEDPin, OUTPUT);
digitalWrite(redLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, LOW);
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
//Reading from the card
String tag = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
tag.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
tag.concat(String(mfrc522.uid.uidByte[i], HEX));
}
tag.toUpperCase();
//Checking the card
if (tag.substring(1) == tagUID) //change here the UID of the card/cards that you want to give access
{
digitalWrite(greenLEDPin, HIGH); //Green LED sequence
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
digitalWrite(greenLEDPin, HIGH);
delay(200);
digitalWrite(greenLEDPin, LOW);
delay(200);
myservo.write(180);
//digitalWrite(greenLed, HIGH);
delay(5000);
//digitalWrite(greenLed, LOW);
myservo.write(0);
}
else
{
// If UID of tag is not matched.
Serial.println ("Access Denied");
digitalWrite(redLEDPin, HIGH); //Red LED sequence
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
digitalWrite(redLEDPin, HIGH);
delay(200);
digitalWrite(redLEDPin, LOW);
delay(200);
}
}
Hi R Lewis! Try the code I posted. I'm surprised it fit. You can also find it on Facebook search #simplekeylessdoorlock
Okay I can just copy and paste it into arduino ide?
@@southerncharmoutdoors6639 yes. It should work
Okay thanks