 In the last video we went over how RFID works and how to set up your own RFID demo where you can scan random cards to see there are unique identification numbers. Then you were able to decide if that card is good or bad so if you wanted to authorize something, not authorize something, whatever you wanted to do identify somebody you could do that using the unique identification numbers. For everything we're going to do in this video it's going to help a lot to understand by watching the other video and then coming back to here. So if you haven't watched it go watch it and then come back. So as I said earlier in the last video we read cards and this one we're going to be writing to them. When it comes to writing information to these RFID cards we're going to need a special card called a M-I-F-A-R-E tag. Usually it's written like MIF error whatever it is and then one kilobyte or whatever the storage is in this case this white card here is a MIF error I don't know what to call it one kilobyte tag which means it has up to one kilobyte of storage. I don't think these tags are going to work but we're going to have to test it out and see if these are able to store any information. These special tags are small electronic devices that use RFID technology to store and transmit information. If you actually take a really bright light I think I'm just going to lower it down a bit and you put it under these cards you can kind of see the coil of wire that goes all the way around the card and then in the top left there the little chip where you can store data and all the RFID magic happens. I wonder if you can actually do that through these two it's going to be a little bit hard because they're so small but I could see it in person but I'm not sure if the camera can pick it up. There's a coil of wire around this way and then right in the middle there's that little storage chip. So these special tags can store data by writing binary information into memory blocks within the RFID chip that we just showed earlier with the light and each block can hold a small amount of data. Then we can read that data through RFID and mess with it, change it, do whatever we want with it but we can pretty much store up to one kilobyte of information on these cards which is not a lot but at least it's something maybe we could put a little message and when you scan that message goes through. Now to write to these cards we're going to be using the same exact system that we built in the last video so like I said if you haven't seen that go watch that video, connect it up like we did it in that video and then come back here so you can work with this part or so you can at least follow along from here. So just plug in the Arduino with the previous demo and let's get started on the code to write information to these cards. Also I'm not exactly sure if these key tags are Miffair, whatever it's called. I think this one is, we're going to have to check that when we read the information off of the cards. So if you watched the last video you found out that you do have to install a library over here for your RFID reader. Once you install libraries they typically come with examples that you can pick out here and file examples and then just go down to the library you downloaded which for us was this one MFRC522 and we're just going to go up here into dump info. This is just a demo file that you can use to read any information off of the card. Pretty much anything the card will hold will get dumped into the serial monitor using this file. So it's not organized, there's nothing special about it, it just gives you absolutely everything that it can read off of these cards. I'm just going to select my board here, I'm going to upload that code to the board and then I want to scan our cards and see first off if they're the Miffair, whatever it's called and then actually see the storage blocks get dumped in the console. We're going to go here, we're going to go serial monitor, we're just going to see what it's being used, 96, 96, scan card to see data blocks. Okay, so we're going to take first our, what I think is compatible Miffair card, we're going to just put it on top here. So we'll open this up a little bit bigger so we can understand what's happening. The first thing is the unique identification number, which is this right here, these eight numbers. Then we have this, I'm not sure what the S-A-K is and then we have our type, which is Miffair one kilobyte. So we know this thing can store some information and if it wasn't obvious, here is our massive data block. I'll put a picture up on the screen but pretty much this card separates into a bunch of different data blocks and then you can store information in all these blocks. It's not a lot of information but there's definitely some things you can do with this. But this is what it looks like when it comes out raw. So if we go to the bottom, we could see zero, zero. There's some things being written down, but if we go to zero, one, to zero, two, three, and all the way up to 1563, no important information written down here. I'm guessing this is just saying end of block. Okay, so we know that card is good to go. Let's clear the console and let's scan one of these tags and see what it says. Oh, look at that. So these are also actually applicable. I pulled the card off so it couldn't read the rest. Look at that. I'm gonna fair one kilobyte. Okay, so these actually work too. So we could store information on these blue tags and we can store information on this big key card and that's by going here. And I guess you do need to hold the card or whatever on until it's done reading because if I pull it off right now, you could see it fails. So I need to hold it there, let it read through the card through the storage and then pull it off when it's done. That's important to know. So you can't just walk up, scan your gym tag and leave. You have to scan and hold it there for a little bit. So if you just run and leave, like it shows right there, time out in communication. All right, that's good to know. So we're not going to close this file. We're just going to keep it open on the side. And then I want to go and open up a new file in Arduino editor. So just file new or I already have it open right here. So for this demo of writing information from the reader to the card, we're just going to use a pre-written code by Rudy Schlaff from MakerCourse.com. This is just a good demo and there's no other way to write it. So I'm just going to use this from the internet. As always, we call the libraries, we call the pins. I have a feeling we're going to have to change these because in our demo, we didn't use those pins. Then we call and we make our MFRC reader object, which is what we did in the last project when we were reading information. Then we have our typical setup here. And then down here is where things start to get complicated. But you could see there's a bunch of different functions. I do a bunch of different things. Like we have a function here that reads the blocks. We have a function here that writes to the blocks. And then at the bottom, what is this? This is read block. So I guess we have those two main functions and the rest happens inside the loop. We also make a variable called block content and we set it to 16 characters. And this is going to be our array of information that we're going to be storing in the key tags. So they put subscribe and an empty thing. We could do whatever we want. So I think this does have to be 16. So let's see if we remove one, two, three, four, five, six, seven, eight, nine, 10, 11, 12, 13, 14, 15. OK, so it's 15, starting from zero. So I just replaced what it said there with testing RFID 1234. This is a pretty simple line and there's no way anyone else would write this. So if we're scanning our card and that comes up, we know that it worked. Over here, there's some nice notes that Rudy put that explains to you kind of what's happening. Like you could see here that we're skipping every fourth block, which when we saw in our earlier project file, the dump info, every fourth one had something written. This is apparently called a trailer block that holds some information where to go. Yeah, so you can see up here, it's a trailer block for access security information. And in our case, we're going to be writing into block number two. Let's connect our Arduino up and upload this piece of code. Now we're going to go and we're going to open up our serial monitor. And I'm going to open this up wide. And now I want to scan this card. I'm going to leave it there and we're going to see what happens in the console. So we could see card selected to is a data block. So it checks if two is a data block block was written block was read. And then read block testing RFID one, two, three, four. Now, one thing I would like to do is go back into dump info. This file right here. And I don't know if you guys remember, but when we read the first time here, I guess it got deleted. When we read the first time, we went through zero one, zero two, zero three, whatever, and we saw that they were all empty. Now I want to see what happens if we go over here. Into dump info. We upload this code to the Arduino and we scan our card if there's going to be something written in the zero two line. Because before it was zero all the way across, and I'll put a picture of that on the screen. Now I want to compare it with what we're going to get when we put the card on here. So I put the card on here. I'm going to let it read. You can see five, four, three, two, one. And now when we go to zero, zero, zero, one, zero, two, we can see one is still empty, but zero two now has something written in there. And that shows us that we were actually writing information on this card. So that lets us know that what we did actually work, that we actually wrote some information on this card. If I take one of our old tags and scan them, I'm just going to hold it there and scroll down. You could see that this thing started the same. And when you go to zero two, it's completely empty. And if we repeated the process of going back to the other file, scanning it, writing to it, whatever, we would see that we're getting the same result. What we can also do is just go here and comment out the right block function. And then we have down here read block, read block, and then read the row. OK, so let's go upload that to the board and let's see what happens when we try this. I'm hoping it doesn't break the program, but it should work if we scan the card. There we go. So card block was selected. Block was read. And then what was read off the block? If it doesn't find anything, does it just exit the program and not let us know? That could be it. Look at that. So we scan the card block was read and there was absolutely nothing there. Zero, zero, zero. So it just gave us kind of this empty air looking thing. But one more time, I could take the old card and I go scan it. It's stuck in the loop. Just refresh that serial monitor, scan the card. You have to just reset the Arduino. I'm guessing this is the thing of the code. But if I just scan the card, boom, we can see that now we're getting that. And if I scan one of the other key tags, you can see that we're getting that. It would also be cool that if a card is being used by somebody and you want to change it with someone else, that you could just rewrite the information on the card. Unfortunately, I don't think you can change the unique identification number on these, but you could definitely do something cool with the data blocks that we went over today. So instead of a 16 character, so instead of a little character string that we put in saying, what was it? Testing RFID 1234, you can maybe put the name of an employee and when they get rid of that card, they get fired, whatever it is, you can give that card to somebody else and change that name of the employee to somebody else. That's it for RFID. And I guess the basics of RFID, I definitely want to use this and more projects in the future. If you have any questions, anything you want to know, let me know in the comments or join the Discord to get some help. And if you enjoy these type of videos, do me a favor and just give the video a like and subscribe so I can keep making this kind of stuff. See you in the next.