Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by ard ( 7 years ago )
#include <Ethernet.h>
#include <SPI.h>
#include <MFRC522.h>
#define NR_OF_READERS 2
#define RST_PIN 9
#define SS_1_PIN 2
#define SS_2_PIN 5
int WARNING = 3;
/* NETWORK */
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x2A, 0x8D };
byte ip[] = { 192, 168, 1, 77 };
byte gw[] = {192, 168, 1, 1};
byte subnet[] = { 255, 255, 255, 0 };
EthernetClient client;//(server, 80);
byte server[] = { 192, 168, 1, 100 }; // Server IP
int data = 1022;
/* NETWORK */
byte ssPins[] = {SS_1_PIN, SS_2_PIN};
MFRC522 mfrc522[NR_OF_READERS];
void setup()
{
Serial.begin(9600);
SPI.begin();
pinMode(WARNING, OUTPUT);
Ethernet.begin(mac, ip, gw, gw, subnet);
if (!Ethernet.begin(mac)) Serial.println(F("failed"));
else Serial.println(F("ok"));
Serial.println(Ethernet.localIP());
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++)
{
mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN);
mfrc522[reader].PCD_DumpVersionToSerial();
}
}
void loop()
{
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++)
{
if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial())
{
Serial.print("Kart Basan Personel:");
senddata();
dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
Serial.println("");
tone(WARNING, 400, 300);
mfrc522[reader].PICC_HaltA();
mfrc522[reader].PCD_StopCrypto1();
}
}
}
void dump_byte_array(byte * buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);
}
}
void senddata()
{
Serial.println("ATE :)");
delay(1000);
if (client.connect(server, 80))
{
Serial.println("Connected");
client.print("GET /test.php?data=");
client.print(data);
client.println("HTTP/1.1");
client.println("Host: 192.168.1.100");
client.println("Connection: close");
client.println();
Serial.println();
while (client.connected())
{
while (client.available())
{
Serial.write(client.read());
}
}
}
else
{
Serial.println("Connection unsuccesful");
}
client.stop();
while (client.status() != 0)
{
delay(5);
}
}
c
Revise this Paste