Advertisement
RuiViana

Teclado 3x4

Nov 15th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. void setup()
  2. {
  3. pinMode(4, OUTPUT);
  4. pinMode(5, OUTPUT);
  5. pinMode(6, OUTPUT);
  6. pinMode(7, OUTPUT);
  7.  
  8. pinMode(8, INPUT);
  9. digitalWrite(8, HIGH);
  10. pinMode(9, INPUT);
  11. digitalWrite(9, HIGH);
  12. pinMode(10, INPUT);
  13. digitalWrite(10, HIGH);
  14.  
  15. Serial.begin(9600);
  16. Serial.println("Teclado 4x3");
  17. Serial.println("Aguardando acionamento");
  18. Serial.println();
  19. }
  20.  
  21. void loop()
  22. {
  23. for(int porta = 4; porta<8; porta ++)
  24. {
  25. digitalWrite(4, HIGH);
  26. digitalWrite(5, HIGH);
  27. digitalWrite(6, HIGH);
  28. digitalWrite(7, HIGH);
  29. digitalWrite(porta, LOW);
  30.  
  31.  
  32. if (digitalRead(8) == LOW)
  33. {
  34. imprime_linha_coluna(porta-3, 1);
  35. while(digitalRead(8) == LOW){}
  36. }
  37. if (digitalRead(9) == LOW)
  38. {
  39. imprime_linha_coluna(porta-3, 2);
  40. while(digitalRead(9) == LOW) {};
  41. }
  42. if (digitalRead(10) == LOW)
  43. {
  44. imprime_linha_coluna(porta-3, 3);
  45. while(digitalRead(10) == LOW) {};
  46. }
  47. }
  48. delay(10);
  49. }
  50. void imprime_linha_coluna(int x, int y)
  51. {
  52. Serial.print("Linha : ");
  53. Serial.print(x);
  54. Serial.print("x Coluna : ");
  55. Serial.print(y);
  56. delay(10);
  57. Serial.println();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement