Oladon

Untitled

Aug 14th, 2011
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #define KBD_CLK_PIN 3
  2. #define KBD_DATA_PIN 4
  3.  
  4. int clock = 0;
  5. int count = 0;
  6. int data = 1;
  7. int in_progress = 0;
  8. int go = 1;
  9.  
  10. void setup() {
  11. pinMode(KBD_CLK_PIN, INPUT);
  12. pinMode(KBD_DATA_PIN, INPUT);
  13.  
  14. Serial.begin(9600);
  15. delay(1000);
  16. }
  17.  
  18. void loop() {
  19. clock = digitalRead(KBD_CLK_PIN);
  20. data = digitalRead(KBD_DATA_PIN);
  21.  
  22. if (clock == 0 && go == 1) {
  23. if (data == 0 && in_progress == 0) {
  24. Serial.print("Test: ");
  25. Serial.print(data);
  26. in_progress = 1;
  27. count++;
  28. } else if (in_progress == 1) {
  29. Serial.print(data);
  30. count++;
  31. if (count == 11) {
  32. Serial.println(":");
  33. count = 0;
  34. in_progress = 0;
  35. }
  36. }
  37. go = 0;
  38. } else {
  39. go = 1;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment