Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define KBD_CLK_PIN 3
- #define KBD_DATA_PIN 4
- int clock = 0;
- int count = 0;
- int data = 1;
- int in_progress = 0;
- int go = 1;
- void setup() {
- pinMode(KBD_CLK_PIN, INPUT);
- pinMode(KBD_DATA_PIN, INPUT);
- Serial.begin(9600);
- delay(1000);
- }
- void loop() {
- clock = digitalRead(KBD_CLK_PIN);
- data = digitalRead(KBD_DATA_PIN);
- if (clock == 0 && go == 1) {
- if (data == 0 && in_progress == 0) {
- Serial.print("Test: ");
- Serial.print(data);
- in_progress = 1;
- count++;
- } else if (in_progress == 1) {
- Serial.print(data);
- count++;
- if (count == 11) {
- Serial.println(":");
- count = 0;
- in_progress = 0;
- }
- }
- go = 0;
- } else {
- go = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment