Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include the library code:
- #include <LiquidCrystal.h>
- // initialize the library with the numbers of the interface pins
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD.
- Serial.begin(9600);
- pinMode(6, INPUT);
- pinMode(13, INPUT);
- pinMode(9, OUTPUT);
- }
- int mainMenu = 1;
- int ustMenu = 0;
- int menu = 0;
- int tempMenu = 0;
- int jasnosc = 100;
- #define up 6
- #define down 7
- #define select 13
- #define back 8
- void loop() {
- lcd.setCursor(0, 1);
- if (mainMenu == 1) {
- if(menu < 0) { menu = 1; }
- if(menu == 0) { lcd.print("1. Temperatura"); }
- if(menu == 1) { lcd.print("2. Ustawienia"); }
- if(menu > 1) { menu = 0; }
- }
- if (ustMenu == 1) {
- if(menu < 0) { menu = 1; }
- if(menu == 0) { lcd.print("1. Jasnosc"); }
- if(menu == 1) { lcd.print("2. Kontrast"); }
- if(menu > 1) { menu = 0; }
- }
- if (tempMenu == 1) {
- lcd.setCursor(0,0);
- lcd.print("Jasnosc: ");
- lcd.setCursor(0,1);
- lcd.print(jasnosc);
- }
- if(digitalRead(up) == HIGH) {
- upKey();
- }
- if(digitalRead(down) == HIGH) {
- downKey();
- }
- if(digitalRead(select) == HIGH) {
- selectKey();
- }
- if(digitalRead(back) == HIGH) {
- backKey();
- }
- }
- int upKey() {
- lcd.clear();
- while(digitalRead(up) == HIGH) {
- }
- menu++;
- }
- int downKey() {
- lcd.clear();
- while(digitalRead(down) == HIGH) {
- }
- menu--;
- }
- int selectKey() {
- lcd.clear();
- while(digitalRead(select) == HIGH) {
- }
- if(menu == 0) {
- lcd.setCursor(0,0);
- lcd.print(analogRead(0));
- }
- if(mainMenu == 1 && menu == 1) {
- ustMenu = 1;
- mainMenu = 0;
- }
- if(ustMenu == 1 && menu == 0) {
- tempMenu = 1;
- ustMenu = 0;
- }
- menu = 0;
- }
- int backKey() {
- lcd.clear();
- while(digitalRead(back) == HIGH) {
- }
- if (ustMenu == 1) {
- ustMenu = 0;
- mainMenu = 1;
- }
- }
- int resMenu(int x) {
- tempMenu = 0;
- mainMenu = 0;
- ustMenu = 0;
- x = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment