SHARE
TWEET

Untitled

a guest Dec 11th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  void setup() {
  4.  
  5.   Serial.begin(9600); //Sets up the serial connection to the serial monitor
  6. int ONE = 23;
  7. int TWO = 22;
  8. int THREE = 21;
  9. int FOUR = 20;
  10. pinMode(ONE, OUTPUT); //set pin 23 to OUTPUT
  11. pinMode(TWO, OUTPUT); //set pin 22 to OUTPUT
  12. pinMode(THREE, OUTPUT); //set pin 21 to OUTPUT
  13. pinMode(FOUR, OUTPUT); //set pin 20 to OUTPUT
  14. int FIVE = 11;
  15. int SIX = 10;
  16. int SEVEN = 9;
  17. int EIGHT = 8;
  18. pinMode(FIVE, INPUT); //set pin 11 to INPUT (read mode)
  19. pinMode(SIX, INPUT); //set pin 10 to INPUT (read mode)
  20. pinMode(SEVEN, INPUT); //set pin 9 to INPUT (read mode)
  21. pinMode(EIGHT, INPUT); //set pin 8 to INPUT (read mode)
  22. }
  23. void loop() {
  24. digitalWrite(23,HIGH); //Ties pin 23 high for matrix detection
  25. if (digitalRead(11) == HIGH) {Serial.print("D4  ");} //Prints "D4" to serial monitor
  26. if (digitalRead(10) == HIGH) {Serial.print("C4  ");} //Prints "C4" to serial monitor
  27. if (digitalRead(9) == HIGH) {Serial.print("A4  ");} //Prints "A4" to serial monitor (note pin 9 and 8 are wired backwards woops)
  28. if (digitalRead(8) == HIGH) {Serial.print("B4  ");} //Prints "B4" to serial monitor (note pin 9 and 8 are wired backwards woops)
  29. digitalWrite(23, LOW);
  30. Serial.println();
  31. delay(100);
  32.  
  33. digitalWrite(22,HIGH); //Ties pin 23 high for matrix detection
  34. if (digitalRead(11) == HIGH) {Serial.print("D3  ");} //Prints "D3" to serial monitor
  35. if (digitalRead(10) == HIGH) {Serial.print("C3  ");} //Prints "C3" to serial monitor
  36. if (digitalRead(9) == HIGH) {Serial.print("A3  ");} //Prints "A3" to serial monitor (note pin 9 and 8 are wired backwards woops)
  37. if (digitalRead(8) == HIGH) {Serial.print("B3  ");} //Prints "B3" to serial monitor (note pin 9 and 8 are wired backwards woops)
  38. digitalWrite(22, LOW);
  39. Serial.println();
  40. delay(100);
  41.  
  42. digitalWrite(21,HIGH); //Ties pin 23 high for matrix detection
  43. if (digitalRead(11) == HIGH) {Serial.print("D2  ");} //Prints "D4" to serial monitor
  44. if (digitalRead(10) == HIGH) {Serial.print("C2  ");} //Prints "C4" to serial monitor
  45. if (digitalRead(9) == HIGH) {Serial.print("A2  ");} //Prints "A4" to serial monitor (note pin 9 and 8 are wired backwards woops)
  46. if (digitalRead(8) == HIGH) {Serial.print("B2  ");} //Prints "B4" to serial monitor (note pin 9 and 8 are wired backwards woops)
  47. digitalWrite(21, LOW);
  48. Serial.println();
  49. delay(100);
  50.  
  51. digitalWrite(20,HIGH); //Ties pin 23 high for matrix detection
  52. if (digitalRead(11) == HIGH) {Serial.print("D1  ");} //Prints "D3" to serial monitor
  53. if (digitalRead(10) == HIGH) {Serial.print("C1  ");} //Prints "C3" to serial monitor
  54. if (digitalRead(9) == HIGH) {Serial.print("A1  ");} //Prints "A3" to serial monitor (note pin 9 and 8 are wired backwards woops)
  55. if (digitalRead(8) == HIGH) {Serial.print("B1  ");} //Prints "B3" to serial monitor (note pin 9 and 8 are wired backwards woops)
  56. digitalWrite(20, LOW);
  57. Serial.println();
  58. delay(100);
  59.  
  60.  
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top