Keypad con i2c

De Proyectos
Saltar a: navegación, buscar

Funcionamiento Básico

Basado en la disposición de los pines de mi Keypad

void setup(){
  Serial.begin(9600);
  pinMode(7, OUTPUT);  //1
  pinMode(8, OUTPUT); //3
  pinMode(9, OUTPUT); //5
  pinMode(6, INPUT_PULLUP); //2
  pinMode(5, INPUT_PULLUP); //4
  pinMode(4, INPUT_PULLUP); //6
  pinMode(3, INPUT_PULLUP); //7
}
void loop(){
  digitalWrite(7, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  if(digitalRead(6) == LOW) Serial.println("2");
  if(digitalRead(5) == LOW) Serial.println("0");
  if(digitalRead(4) == LOW) Serial.println("8");
  if(digitalRead(3) == LOW) Serial.println("5");
  digitalWrite(7, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(9, HIGH);
  if(digitalRead(6) == LOW) Serial.println("1");
  if(digitalRead(5) == LOW) Serial.println("*");
  if(digitalRead(4) == LOW) Serial.println("7");
  if(digitalRead(3) == LOW) Serial.println("4");
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, LOW);
  if(digitalRead(6) == LOW) Serial.println("3");
  if(digitalRead(5) == LOW) Serial.println("#");
  if(digitalRead(4) == LOW) Serial.println("9");
  if(digitalRead(3) == LOW) Serial.println("6");

}