Advertisement
Guest User

Text Input arduino (directional buttons) 5 buttons

a guest
Jan 10th, 2015
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2. LiquidCrystal lcd(7,6,5,4,3,2);
  3. int i=0;
  4. char input[] = "a";
  5. const int dw = 8;
  6. const int ri = 9;
  7. const int le = 10;
  8. const int up = 11;
  9. const int ok = 12;
  10. const int mn = 13;
  11.  
  12. int bdw=0, bri=0, ble=0, beu=0, beo=0, bem=0;
  13.  
  14. void setup()
  15. {
  16. pinMode(dw, INPUT);
  17. pinMode(ri, INPUT);
  18. pinMode(le, INPUT);
  19. pinMode(up, INPUT);
  20. pinMode(ok, INPUT);
  21. pinMode(mn, INPUT);
  22. }
  23. void intext()
  24. {
  25. int lim=16;
  26. lcd.setCursor(0,1);
  27. lcd.print(input);
  28. for(i=0; i<lim ; )
  29. {
  30. lcd.setCursor(0,1);
  31. lcd.print(input);
  32. if(digitalRead(dw)==HIGH)
  33. {
  34. if(input[i]>'z')
  35. input[i]='a';
  36. input[i]=input[i]+1;
  37. delay(500);
  38. }
  39. if(digitalRead(up)==HIGH)
  40. {
  41. if(input[i]<'a')
  42. input[i]='z';
  43. input[i]=input[i]-1;
  44. delay(500);
  45. }
  46. if(digitalRead(ri)==HIGH)
  47. {
  48. delay(500);
  49. i=i+1;
  50. }
  51. if(digitalRead(le)==HIGH)
  52. {
  53. delay(500);
  54. i=i-1;
  55. }
  56. if(digitalRead(ok)==HIGH)
  57. {
  58. lim=i;
  59. delay(500);
  60. }
  61. }
  62. }
  63.  
  64. void loop()
  65. {
  66. lcd.begin(16,2);
  67. lcd.setCursor(0,0);
  68. lcd.print("Type text:");
  69. intext();
  70. lcd.clear();
  71. lcd.setCursor(0,0);
  72. lcd.print("Success!!");
  73. lcd.setCursor(0,1);
  74. lcd.print(input);
  75. delay(5000);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement