Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup()
- {
- pinMode(4, OUTPUT);
- pinMode(5, OUTPUT);
- pinMode(6, OUTPUT);
- pinMode(7, OUTPUT);
- pinMode(8, INPUT);
- digitalWrite(8, HIGH);
- pinMode(9, INPUT);
- digitalWrite(9, HIGH);
- pinMode(10, INPUT);
- digitalWrite(10, HIGH);
- Serial.begin(9600);
- Serial.println("Teclado 4x3");
- Serial.println("Aguardando acionamento");
- Serial.println();
- }
- void loop()
- {
- for(int porta = 4; porta<8; porta ++)
- {
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- digitalWrite(6, HIGH);
- digitalWrite(7, HIGH);
- digitalWrite(porta, LOW);
- if (digitalRead(8) == LOW)
- {
- imprime_linha_coluna(porta-3, 1);
- while(digitalRead(8) == LOW){}
- }
- if (digitalRead(9) == LOW)
- {
- imprime_linha_coluna(porta-3, 2);
- while(digitalRead(9) == LOW) {};
- }
- if (digitalRead(10) == LOW)
- {
- imprime_linha_coluna(porta-3, 3);
- while(digitalRead(10) == LOW) {};
- }
- }
- delay(10);
- }
- void imprime_linha_coluna(int x, int y)
- {
- Serial.print("Linha : ");
- Serial.print(x);
- Serial.print("x Coluna : ");
- Serial.print(y);
- delay(10);
- Serial.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement