Hello genius internet coders,
For some reason my circuit does not work (even though powered) when my computer is unplugged from it.
Something to note is that I'm trying to run it on 6V power supply, so to avoid the voltage regulator at Vin I have put in the voltage through the 5V pin, this sounds sketchy but it does in fact power the micro and my modules. I also tested running 7V into the Vin (the recommended amount) and it still didn't work (even though the lights were on, signifying that it was powered). Is it possible that the code is causing my computer to do the processing rather than the micro?
Any help is much appreciated, this is for my year 12 engineering project which contributes to my finals, and my time is quickly running out.
Here is my main code: (used an internet tutorial, edited it slightly)
/*
*
* All the resources for this project: https://randomnerdtutorials.com/
* Modified by Rui Santos
*
* Created by FILIPEFLOP
*
*/
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("Approximate your card to the reader...");
Serial.println();
pinMode(5, OUTPUT); //sets pin 5 as an output
pinMode(3, OUTPUT);
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "4D 42 CD D7") //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized access");
Serial.println();
digitalWrite(5, HIGH);
delay(5000);
digitalWrite(5, LOW);
delay(1000);
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(5, HIGH);
delay(5000);
digitalWrite(5, LOW);
digitalWrite(3, LOW);
}
else {
Serial.println(" Access denied");
delay(3000);
}
}
And here is my code after I removed all of the serial monitor code, as I thought it might be an error to do with a lack of connection to the serial monitor when unplugged to the computer.
/*
*
* All the resources for this project: https://randomnerdtutorials.com/
* Modified by Rui Santos
*
* Created by FILIPEFLOP
*
*/
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
pinMode(5, OUTPUT); //sets pin 5 as an output
pinMode(3, OUTPUT);
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
content.toUpperCase();
if (content.substring(1) == "4D 42 CD D7") //change here the UID of the card/cards that you want to give access
{
digitalWrite(5, HIGH);
delay(5000);
digitalWrite(5, LOW);
delay(1000);
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(5, HIGH);
delay(5000);
digitalWrite(5, LOW);
digitalWrite(3, LOW);
}
else {
delay(3000);
}
}
Any help is greatly appreciated, thanks