Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RESET_PIN 2
- #define CLK_PIN 3
- #define IO_PIN 4
- #define LEN 32
- unsigned long multiplier = 1;
- void setup()
- {
- pinMode(RESET_PIN, OUTPUT);
- pinMode(CLK_PIN, OUTPUT);
- pinMode(IO_PIN, INPUT);
- Serial.begin(115200);
- Serial.println("Ready.");
- }
- byte atr[LEN];
- int index = 0;
- void loop()
- {
- reset();
- for(index = 0; index < LEN; index++)
- {
- clk(index);
- }
- for(index = 0; index < LEN; index++)
- {
- Serial.print(atr[index]);
- }
- Serial.println();
- delay(3000);
- }
- void clk(int i)
- {
- delayMicroseconds(60 * multiplier);
- digitalWrite(RESET_PIN, HIGH);
- delayMicroseconds(10 * multiplier);
- atr[i] = digitalRead(IO_PIN);
- delayMicroseconds(10 * multiplier);
- digitalWrite(RESET_PIN, LOW);
- }
- void reset()
- {
- digitalWrite(RESET_PIN, HIGH);
- delayMicroseconds(60 * multiplier);
- digitalWrite(CLK_PIN, HIGH);
- delayMicroseconds(30 * multiplier);
- digitalWrite(CLK_PIN, LOW);
- delayMicroseconds(20 * multiplier);
- digitalWrite(RESET_PIN, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement