Guest User

Untitled

a guest
Nov 8th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.02 KB | None | 0 0
  1. // include the library code:
  2. #include <LiquidCrystal.h>
  3.  
  4. // initialize the library with the numbers of the interface pins
  5. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  6.  
  7. void setup() {
  8.   // set up the LCD's number of columns and rows:
  9.   lcd.begin(16, 2);
  10.   // Print a message to the LCD.
  11.   Serial.begin(9600);
  12.   pinMode(6, INPUT);
  13.   pinMode(13, INPUT);
  14.   pinMode(9, OUTPUT);
  15. }
  16. int mainMenu = 1;
  17. int ustMenu = 0;
  18. int menu = 0;
  19. int tempMenu = 0;
  20. int jasnosc = 100;
  21.  
  22. #define up 6
  23. #define down 7
  24. #define select 13
  25. #define back 8
  26.  
  27. void loop() {
  28.  
  29.   lcd.setCursor(0, 1);
  30.   if (mainMenu == 1) {
  31.     if(menu < 0) { menu = 1; }
  32.     if(menu == 0) { lcd.print("1. Temperatura"); }
  33.     if(menu == 1) { lcd.print("2. Ustawienia"); }
  34.     if(menu > 1) { menu = 0; }
  35.   }
  36.   if (ustMenu == 1) {
  37.     if(menu < 0) { menu = 1; }
  38.     if(menu == 0) { lcd.print("1. Jasnosc"); }
  39.     if(menu == 1) { lcd.print("2. Kontrast"); }
  40.     if(menu > 1) { menu = 0; }
  41.   }
  42.   if (tempMenu == 1) {
  43.     lcd.setCursor(0,0);
  44.     lcd.print("Jasnosc: ");
  45.     lcd.setCursor(0,1);
  46.     lcd.print(jasnosc);
  47.   }
  48.  
  49.   if(digitalRead(up) == HIGH) {
  50.     upKey();
  51.   }
  52.   if(digitalRead(down) == HIGH) {
  53.     downKey();
  54.   }
  55.   if(digitalRead(select) == HIGH) {
  56.     selectKey();
  57.   }
  58.   if(digitalRead(back) == HIGH) {
  59.     backKey();
  60.   }
  61. }
  62. int upKey() {
  63.   lcd.clear();
  64.   while(digitalRead(up) == HIGH) {
  65.   }
  66.   menu++;
  67. }
  68. int downKey() {
  69.   lcd.clear();
  70.   while(digitalRead(down) == HIGH) {
  71.   }
  72.   menu--;
  73. }
  74. int selectKey() {
  75.   lcd.clear();
  76.   while(digitalRead(select) == HIGH) {
  77.   }
  78.   if(menu == 0) {
  79.     lcd.setCursor(0,0);
  80.     lcd.print(analogRead(0));
  81.   }
  82.   if(mainMenu == 1 && menu == 1) {
  83.     ustMenu = 1;
  84.     mainMenu = 0;
  85.   }
  86.   if(ustMenu == 1 && menu == 0) {
  87.     tempMenu = 1;
  88.     ustMenu = 0;
  89.   }
  90.   menu = 0;
  91. }
  92. int backKey() {
  93.   lcd.clear();
  94.   while(digitalRead(back) == HIGH) {
  95.   }
  96.   if (ustMenu == 1) {
  97.     ustMenu = 0;
  98.     mainMenu = 1;
  99.   }
  100. }
  101. int resMenu(int x) {
  102.   tempMenu = 0;
  103.   mainMenu = 0;
  104.   ustMenu = 0;
  105.   x = 1;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment