Hodge-1053 icon

Arduino: Keypad with 7-Segment Display

Hodge-1053 | PRO | 10/29/22 04:40:42 PM UTC (Edited) | 0 ⭐ | 1330 👁️ | Never ⏰ | []
C |

1.53 KB

|

Source Code

|

0 👍

/

0 👎

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
 
LiquidCrystal_I2C lcd(0x27, 20, 4);
 
const int a = 23;
const int b = 25;
const int c = 27;
const int d = 29;
const int e = 31;
const int f = 33;
const int g = 35;
const int p = 37;
 
const int Rows = 4;
const int Cols = 4;
 
char keys [Rows][Cols] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
 
byte rowPins [Rows] = {1,2,3,4};
byte colPins [Cols] = {5,6,7,8};
 
Keypad keypad = Keypad (makeKeymap(keys), rowPins, colPins, Rows, Cols);
 
void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.clear();
  lcd.setCursor(0, 0);
 
  pinMode(p, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
}
 
void keyPress()
{
  char key = keypad.getKey();
  if (key)
  {
    lcd.clear();
    lcd.print("U Pressed: ");
    lcd.print(key);
  }
 
  if (key == '1')
  {
    digitalWrite(a, HIGH);
  }
 
  else if (key == '2')
  {
    digitalWrite(b, HIGH);
  }
 
  else if (key == '3')
  {
    digitalWrite(c, HIGH);
  }
 
  else if (key == '4')
  {
    digitalWrite(d, HIGH);
  }
 
  else if (key == '5')
  {
    digitalWrite(e, HIGH);
  }
 
  else if (key == '6')
  {
    digitalWrite(f, HIGH);
  }
 
  else if (key == '7')
  {
    digitalWrite(g, HIGH);
  }
 
  else if (key == '8')
  {
    digitalWrite(p, HIGH);
  }
}
void loop()
{
  keyPress();
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Duizxy icon
    05/16/26 11:49:15 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400