SHARE
TWEET

Smartcard reset

a guest Jan 5th, 2017 3 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define RESET_PIN 2
  2. #define CLK_PIN 3
  3. #define IO_PIN 4
  4.  
  5. #define LEN 32
  6.  
  7. unsigned long multiplier = 1;
  8.  
  9. void setup()
  10. {
  11.   pinMode(RESET_PIN, OUTPUT);
  12.   pinMode(CLK_PIN, OUTPUT);
  13.   pinMode(IO_PIN, INPUT);
  14.  
  15.   Serial.begin(115200);
  16.   Serial.println("Ready.");
  17. }
  18.  
  19. byte atr[LEN];
  20. int index = 0;
  21. void loop()
  22. {
  23.   reset();
  24.   for(index = 0; index < LEN; index++)
  25.   {
  26.     clk(index);
  27.   }
  28.   for(index = 0; index < LEN; index++)
  29.   {
  30.     Serial.print(atr[index]);
  31.   }
  32.   Serial.println();
  33.   delay(3000);
  34. }
  35.  
  36. void clk(int i)
  37. {
  38.   delayMicroseconds(60 * multiplier);
  39.   digitalWrite(RESET_PIN, HIGH);
  40.   delayMicroseconds(10 * multiplier);
  41.   atr[i] = digitalRead(IO_PIN);
  42.   delayMicroseconds(10 * multiplier);
  43.   digitalWrite(RESET_PIN, LOW);
  44. }
  45.  
  46. void reset()
  47. {
  48.   digitalWrite(RESET_PIN, HIGH);
  49.   delayMicroseconds(60 * multiplier);
  50.   digitalWrite(CLK_PIN, HIGH);
  51.   delayMicroseconds(30 * multiplier);
  52.   digitalWrite(CLK_PIN, LOW);
  53.   delayMicroseconds(20 * multiplier);
  54.   digitalWrite(RESET_PIN, LOW);
  55. }
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top