License

Recommend Projects

5 Button Keyboards

4 years ago 687
  • Description
  • Documents
  • BOM
  • Attachments
  • Members
  • Comments

Description

Arduino drives 5 button keyboard

5 button keyboard: the use of series resistor and switch to determine the various voltage to be sent to a Arduino analog input.You can use the same technology to install multiple buttons in other ways or directions.

5 button keyboards CODE



#define keyboard_AnalogInput 5

#define btRIGHT  0
#define btUP     1
#define btDOWN   2
#define btLEFT   3
#define btENTER 4
#define NONE   5

int ad_keyd = 0;
int buttonPressed;

void setup()   
    {
  Serial.begin(9600);
  Serial.println("5 button keyboards");
     }

void loop()  
{
  buttonPressed = read_keyboard();
  if (buttonPressed != NONE)
  { 
     Serial.print("OK easyeda pressed ");
    Serial.println(buttonPressed, DEC);
    } 
  delay(500);
}
// read the buttons
int read_keyboard()
{
   ad_keyd = analogRead(keyboard_AnalogInput); 
  // these values: 0, 144, 329, 504, 741
  if (adc_key_in > 1000) return NONE; 
  if (adc_key_in < 50) return btRIGHT;
  if (adc_key_in < 195) return btUP;
  if (adc_key_in < 380) return btDOWN;
  if (adc_key_in < 555) return btLEFT;
  if (adc_key_in < 790) return btENTER;
  return NONE; // when all others fail.
}

Documents

5 Button keyboards

BOM

ID Name Designator Footprint Quantity
1 KEY K1,K2,K3,K4,K5 NONE 5
2 330 R1 R3 1
3 620 R2 R3 1
4 1k R3 R3 1
5 3.3k R4 R3 1
6 2k R5 R3 1
7 Arduino MEGA 2560 U1 DIP 1

Attachments

None

Members

Success
The owner does not allow comments in this project now

Comments (0)

goToTop
你现在访问的是EasyEDA海外版,使用建立访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.