d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Arduino Uno
Prev12
Add Reply New Topic New Poll
Member
Posts: 3,666
Joined: Oct 28 2014
Gold: 46.01
Jan 11 2017 02:23am
Quote (AbDuCt @ Jan 11 2017 04:07am)

What this should theoretically do is keep setting the pin high while the rfid tag is being read and it matches one of the two ids. Then when the rfid tag is removed it should set it low.


The pins need to be LOW when the tag is present though, but that's as simple as just switching them around in the code right?

Do you have anywhere we can just chat instead of posting here all the time for when I have a question? discord chat or a skype chat or something?

This post was edited by SIKKaudio on Jan 11 2017 02:36am
Member
Posts: 3,666
Joined: Oct 28 2014
Gold: 46.01
Jan 11 2017 04:43am
I made a new sketch with your code and get a few errors, I'm trying to work them out, if I get em worked out ill post here to.

Code
#include <SPI.h>
#include <MFRC522.h>

#include <SPI.h>
#include <MFRC522.h>

#define koffie 2
#define thee 2

#define RST_PIN 9
#define SS_PIN 10

MFRC522 mfrc522(SS_PIN, RST_PIN);

int koffiePin = 13; //changed to pin 13 for testing (2)
int theePin = 13; //changed to pin 13 for testing (3)

String *koffie_rfid[] = { "46e6868d", "5aadebb" };
String *thee_rfid[] = { "46528b8d", "ea35fbb" };

/**
* Initialize
*/
void setup() {
Serial.begin(9600); //9600 = speed
while (!Serial);
SPI.begin();
mfrc522.PCD_Init();
pinMode(koffiePin, OUTPUT);
pinMode(theePin, OUTPUT);
}
/*
* Helper routine to dump a byte array as hex values to Serial
*/
void dump_byte_array(byte *buffer, byte bufferSize) {
read_rfid="";
for (byte i = 0; i < bufferSize; i++) {
read_rfid=read_rfid + String(buffer[i], HEX);
}

bool card_in_place() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
digitalWrite(koffiePin, LOW);
digitalWrite(theePin, LOW);
return false;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial ()) {
digitalWrite(koffiePin, LOW);
digitalWrite(theePin, LOW);
return false;
}

return true
}

void loop() {

if(!card_in_place)
return;

for(int i = 0; i <= koffies; i++) {
if(koffie_rfid[i] == read_rfid) {
digitalWrite(koffiePin, HIGH);
}
}

for(int i = 0; i <= thees; i++) {
if(thee_rfid[i] == read_rfid) {
digitalWrite(theePin, HIGH);
}
}
}


ERROR:
I can't figure out why it keeps making a second library it's starting to bug me.

Code
Arduino: 1.6.13 (Windows 10), Board: "Arduino/Genuino Uno"

Test_Code_Single_Scanner_JSP:18: error: cannot convert 'const char*' to 'String*' in initialization

String *koffie_rfid[] = { "46e6868d", "5aadebb" };

^

Test_Code_Single_Scanner_JSP:18: error: cannot convert 'const char*' to 'String*' in initialization

Test_Code_Single_Scanner_JSP:19: error: cannot convert 'const char*' to 'String*' in initialization

String *thee_rfid[] = { "46528b8d", "ea35fbb" };

^

Test_Code_Single_Scanner_JSP:19: error: cannot convert 'const char*' to 'String*' in initialization

C:\Users\harms\OneDrive\Stage Project Arduino\Arduino Stuff\Test_Code_Single_Scanner_JSP\Test_Code_Single_Scanner_JSP.ino: In function 'void dump_byte_array(byte*, byte)':

Test_Code_Single_Scanner_JSP:36: error: 'read_rfid' was not declared in this scope

read_rfid="";

^

Test_Code_Single_Scanner_JSP:41: error: a function-definition is not allowed here before '{' token

bool card_in_place() {

^

Test_Code_Single_Scanner_JSP:75: error: expected '}' at end of input

}

^

Multiple libraries were found for "MFRC522.h"
Used: C:\Users\harms\OneDrive\Arduino Sketchbook\libraries\MFRC522
Not used: C:\Program Files (x86)\Arduino\libraries\rfid
exit status 1
cannot convert 'const char*' to 'String*' in initialization

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jan 11 2017 07:46am
I'll be able to help in about 8 hours or so over discord if you want to send me your username over pm. I see a few things wrong which are easy fixes. One was my bad, it should be string xxxx[] not string *XXX[]. Another is read_rfid should be declared as a global or refactored to be passed by reference to the function like how buffer is.

Edit:: and yes in this implantation you can just reverse the values high/low to generate the required states of the pins.

This post was edited by AbDuCt on Jan 11 2017 07:50am
Member
Posts: 3,666
Joined: Oct 28 2014
Gold: 46.01
Jan 12 2017 01:21am
Quote (AbDuCt @ Jan 11 2017 03:46pm)
I'll be able to help in about 8 hours or so over discord if you want to send me your username over pm. I see a few things wrong which are easy fixes. One was my bad, it should be string xxxx[] not string *XXX[]. Another is read_rfid should be declared as a global or refactored to be passed by reference to the function like how buffer is.

Edit:: and yes in this implantation you can just reverse the values high/low to generate the required states of the pins.


hey thanks man, adding you on discord now, name is same as on here
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll