• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
panel led z matryc led 8x8 + menu na lcd 2x16 + przyciski
#1
Witam, cześć.

Od kilku miesięcy bawię się Arduino Uno i uczę się programować na poniższym projekcie i mam kilka pytań.



moje założenia to:

wyświetlacz/panel led zbudowany z matryc LED 8x8 (MAX7219) - (na razie mam 4 sztuki)
sterowany za pomocą przycisków i menu na wyświetlaczu lcd 2x16.

wybieram sobie napis za pomocą przycisków (przyciski to: wróć, góra, dół, ok)
klikam ok i leci napis, jak chcę zmienić napis to wciskam przycisk wróć, 
wybieram inny napis z menu i naciskam ok i leci następny napis

co mi się udasło:

Udało mi się pozmieniać kody z następujących poradników/tutoriali i uzyskać to,
co założyółem

obsługa matryc led 8x8:
https://brainy-bits.com/blogs/tutorials/...dot-matrix
(wybrałem ten, ponieważ udało mi się uzyskać polskie znaki)

menu z przyciskami + wyświetlacz lcd 2x16:
http://www.instructables.com/id/Arduino-...-Template/

no ale apetyt rośnie .....

   

problemy:


1. przycisk "wróć" działa tylko kiedy koniec napisu jest na ostatniej matrycy led (pierwszej z lewej).

Jak zrobić żeby przycisk wstecz działał w dowolnym położeniu napisu ??

Tak naprawdę kod który wyświetla/przewija napis:

//napis matrix led---------------------------------------------------  
    byte c;
    delay(100);
    m.shiftLeft(false, true);
    printStringWithShift(string1, 80);  // Send scrolling Text
//napis matrix led--------------------------------------------------- 

wklejałem metodą prób i błędów w instrukcji "switch case" i na pewno to jest tego przyczyną ;]



2. chciałbym aby napis był większy, to znaczy, zęby połącz matryce led w pionie  16:32 (po dodaniu kolejnych 4 matryc led 8x8).

na githubie znalazłem przykład, który to umożliwia, ale tu nie mogę uzyskać polskich znaków. Wiem że poszczególne litery są w pliku >> glcdfont.c <<,
który jest w -> libraries\Adafruit-GFX-Library-master i nie umiem pozmieniać znaków na polskie litery jak
"moim" (działającym) przykładzie - zamieniłem {}[] na łżźó - nie wszstkie znaki są mi potrzebne

Czy jest jakaś szansa na przerobienie pliku glcdfont.c w taki sam sposób jak ja to zrobiłem w "moim" projekcie?






wrzuciłem na Youtub film jak to działa:
https://www.youtube.com/watch?v=zXt-wpAq...e=youtu.be



a tu kod arduino:

########################################################################

Kod:
// poszcególne litery do wyświetlacza  - niektóre znaki zostały zmienione na polskie  -------------------
PROGMEM const unsigned char CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
4, 8, B00111000, B01010100, B01010100, B10011000, B00000000, //[ zmienione na ę
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, 8, B01001001, B01111111, B01010000, B00000000, B00000000, // { zmienione na ł
3, 8, B01100100, B01010110, B01001101, B00000000, B00000000, // | zmieniona na ź
3, 8, B01100100, B01010101, B01001100, B00000000, B00000000, // } zmieniona na ż
4, 8, B00111000, B01000100, B01000110, B00111001, B00000000, // ~ zmieniona na ó
};

// znalezione w internecie
//http://www.instructables.com/id/Arduino-Uno-Menu-Template/
//- oryginalnie pan Paul używa wyświetlacza z wbudowanymi przyciskami ( DFRobot LCD Keypad Shield )
// ja mam zwykły lcd 2x16 więc dodałem przyciski tact switch tht
/***************************************************************************************
   Name    : LCD Button Shield Menu
   Author  : Paul Siewert
   Created : June 14, 2016
   Last Modified: June 14, 2016
   Version : 1.0
   Notes   : This code is for use with an Arduino Uno and LCD/button shield. The
             intent is for anyone to use this program to give them a starting
             program with a fully functional menu with minimal modifications
             required by the user.
   License : This program is free software. You can redistribute it and/or modify
             it under the terms of the GNU General Public License as published by
             the Free Software Foundation, either version 3 of the License, or
             (at your option) any later version.
             This program is distributed in the hope that it will be useful,
             but WITHOUT ANY WARRANTY; without even the implied warranty of
             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
             GNU General Public License for more details.
***************************************************************************************/
/*
  This program is designed to get you as close as possible to a finished menu for the standard Arduino Uno LCD/button shield. The only required modifications
  are to add as menu items to the master menu (menuItems array) and then modify/adjust the void functions below for each of those selections.
*/

// You can have up to 10 menu items in the menuItems[] array below without having to change the base programming at all. Name them however you'd like. Beyond 10 items, you will have to add additional "cases" in the switch/case
// section of the operateMainMenu() function below. You will also have to add additional void functions (i.e. menuItem11, menuItem12, etc.) to the program.
String menuItems[] = {"NAPIS 1", "NAPIS 2", "NAPIS 3", "NAPIS 4", "NAPIS 5", "NAPIS 6"};

// Navigation button variables
int readKey;

// Menu control variables
int menuPage = 0;
int maxMenuPages = round(((sizeof(menuItems) / sizeof(String)) / 2) + .5);
int cursorPosition = 0;

// Creates 3 custom characters for the menu display
byte downArrow[8] = {
 0b00100, //   *
 0b00100, //   *
 0b00100, //   *
 0b00100, //   *
 0b00100, //   *
 0b10101, // * * *
 0b01110, //  ***
 0b00100  //   *
};

byte upArrow[8] = {
 0b00100, //   *
 0b01110, //  ***
 0b10101, // * * *
 0b00100, //   *
 0b00100, //   *
 0b00100, //   *
 0b00100, //   *
 0b00100  //   *
};

byte menuCursor[8] = {
 B01000, //  *
 B00100, //   *
 B00010, //    *
 B00001, //     *
 B00010, //    *
 B00100, //   *
 B01000, //  *
 B00000  //
};


//Dołączenie bilbiotek
#include "MaxMatrix.h"
#include "avr/pgmspace.h"
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(5, 6, 7, 8, 9, 10); //Informacja o podłączeniu wyświetlacza lcd


//wyżej wspomniane przyciski
// --- definicje przycisków ----------------------------------------------
#define bRight 11 // przycisk OK   na pinie 11 - wejscie w opcje - enter
#define bUp 3     // przycisk UP   na pinie 3  - góra
#define bDown 4   // przycisk DOWN na pinie 4  - dół
#define bLeft 2   // przycisk BACK na pinie 2  - w lewo - wyjscie - esc
// --- definicje przycisków ----------------------------------------------


//na podstawie, a raczej po niewielkich zmianach :
// https://brainy-bits.com/blogs/tutorials/scroll-text-using-the-max7219-led-dot-matrix
// wyświetlacze led matrix------------------------------------------------
int data = 1;    // DIN pin of MAX7219 module
int load = 12;    // CS pin of MAX7219 module
int clock = 13;  // CLK pin of MAX7219 module

int maxInUse = 4;  //how many MAX7219 are connected

MaxMatrix m(data, load, clock, maxInUse); // define Library

byte buffer[10];


// Scrolling Text - napisy wyświetlane na MAX7219

char string1[] = " 1111111      ";
char string2[] = " 2222222      ";
char string3[] = " 3333333      ";
char string4[] = " 4444444      ";





void setup() {

 
//wyświetlacz led---------------------------------------------------------  
 m.init(); // module MAX7219
 m.setIntensity(5); // LED Intensity 0-15
//wyświetlacz led---------------------------------------------------------  


 // Initializes and clears the LCD screen
 lcd.begin(16, 2);
 lcd.clear();

 // Creates the byte for the 3 custom characters
 lcd.createChar(0, menuCursor);
 lcd.createChar(1, upArrow);
 lcd.createChar(2, downArrow);

 pinMode(bRight,INPUT_PULLUP);    // konfiguracja pinów dla przycisków
 pinMode(bUp,INPUT_PULLUP);       // konfiguracja pinów dla przycisków
 pinMode(bDown,INPUT_PULLUP);     // konfiguracja pinów dla przycisków
 pinMode(bLeft,INPUT_PULLUP);     // konfiguracja pinów dla przycisków
}

void loop() {
 mainMenuDraw();
 drawCursor();
 operateMainMenu();
}


//  ----------------koniec programu-----------------
//  |               FUNKCJE                        |
//  ------------------------------------------------
//  przyznaje bez bicia, że nie wszystkie rozumiem

//  |Put extracted character on Display      |
void printCharWithShift(char c, int shift_speed){
 if (c < 32) return;
 c -= 32;
 memcpy_P(buffer, CH + 7*c, 7);
 m.writeSprite(maxInUse*8, 0, buffer);
 m.setColumn(maxInUse*8 + buffer[0], 0);
 
 for (int i = 0; i < buffer[0]+1; i++)
 {
   delay(shift_speed);
   m.shiftLeft(false, false);
 }
}

// Extract characters from Scrolling text
void printStringWithShift(char* s, int shift_speed){
 while (*s != 0){
   printCharWithShift(*s, shift_speed);
   s++;
 }
}

// This function will generate the 2 menu items that can fit on the screen. They will change as you scroll through your menu. Up and down arrows will indicate your current menu position.
void mainMenuDraw() {
 Serial.print(menuPage);
 lcd.clear();
 lcd.setCursor(1, 0);
 lcd.print(menuItems[menuPage]);
 lcd.setCursor(1, 1);
 lcd.print(menuItems[menuPage + 1]);
 if (menuPage == 0) {
   lcd.setCursor(15, 1);
   lcd.write(byte(2));
 } else if (menuPage > 0 and menuPage < maxMenuPages) {
   lcd.setCursor(15, 1);
   lcd.write(byte(2));
   lcd.setCursor(15, 0);
   lcd.write(byte(1));
 } else if (menuPage == maxMenuPages) {
   lcd.setCursor(15, 0);
   lcd.write(byte(1));
 }
}

// When called, this function will erase the current cursor and redraw it based on the cursorPosition and menuPage variables.
void drawCursor() {
 for (int x = 0; x < 2; x++) {     // Erases current cursor
   lcd.setCursor(0, x);
   lcd.print(" ");
 }

 // The menu is set up to be progressive (menuPage 0 = Item 1 & Item 2, menuPage 1 = Item 2 & Item 3, menuPage 2 = Item 3 & Item 4), so
 // in order to determine where the cursor should be you need to see if you are at an odd or even menu page and an odd or even cursor position.
 if (menuPage % 2 == 0) {
   if (cursorPosition % 2 == 0) {  // If the menu page is even and the cursor position is even that means the cursor should be on line 1
     lcd.setCursor(0, 0);
     lcd.write(byte(0));
   }
   if (cursorPosition % 2 != 0) {  // If the menu page is even and the cursor position is odd that means the cursor should be on line 2
     lcd.setCursor(0, 1);
     lcd.write(byte(0));
   }
 }
 if (menuPage % 2 != 0) {
   if (cursorPosition % 2 == 0) {  // If the menu page is odd and the cursor position is even that means the cursor should be on line 2
     lcd.setCursor(0, 1);
     lcd.write(byte(0));
   }
   if (cursorPosition % 2 != 0) {  // If the menu page is odd and the cursor position is odd that means the cursor should be on line 1
     lcd.setCursor(0, 0);
     lcd.write(byte(0));
   }
 }
}


void operateMainMenu() {
 int activeButton = 0;
 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 0: // When button returns as 0 there is no action taken
       break;
     case 1:  // This case will execute if the "forward" button is pressed
       button = 0;
       switch (cursorPosition) { // The case that is selected here is dependent on which menu page you are on and where the cursor is.
         case 0:
           menuItem1();
           break;
         case 1:
           menuItem2();
           break;
         case 2:
           menuItem3();
           break;
         case 3:
           menuItem4();
           break;
         case 4:
           menuItem5();
           break;
         case 5:
           menuItem6();
           break;
         case 6:
           menuItem7();
           break;
         case 7:
           menuItem8();
           break;
         case 8:
           menuItem9();
           break;
         case 9:
           menuItem10();
           break;
       }
       activeButton = 1;
       mainMenuDraw();
       drawCursor();
       break;
     case 2:
       button = 0;
       if (menuPage == 0) {
         cursorPosition = cursorPosition - 1;
         cursorPosition = constrain(cursorPosition, 0, ((sizeof(menuItems) / sizeof(String)) - 1));
       }
       if (menuPage % 2 == 0 and cursorPosition % 2 == 0) {
         menuPage = menuPage - 1;
         menuPage = constrain(menuPage, 0, maxMenuPages);
       }

       if (menuPage % 2 != 0 and cursorPosition % 2 != 0) {
         menuPage = menuPage - 1;
         menuPage = constrain(menuPage, 0, maxMenuPages);
       }

       cursorPosition = cursorPosition - 1;
       cursorPosition = constrain(cursorPosition, 0, ((sizeof(menuItems) / sizeof(String)) - 1));

       mainMenuDraw();
       drawCursor();
       activeButton = 1;
       break;
     case 3:
       button = 0;
       if (menuPage % 2 == 0 and cursorPosition % 2 != 0) {
         menuPage = menuPage + 1;
         menuPage = constrain(menuPage, 0, maxMenuPages);
       }

       if (menuPage % 2 != 0 and cursorPosition % 2 == 0) {
         menuPage = menuPage + 1;
         menuPage = constrain(menuPage, 0, maxMenuPages);
       }

       cursorPosition = cursorPosition + 1;
       cursorPosition = constrain(cursorPosition, 0, ((sizeof(menuItems) / sizeof(String)) - 1));
       mainMenuDraw();
       drawCursor();
       activeButton = 1;
       break;
   }
 }
}

// This function is called whenever a button press is evaluated. The LCD shield works by observing a voltage drop across the buttons all hooked up to A0.
int evaluateButton(int x) {
 int result = 0;
 if (digitalRead(bRight)==LOW) {
   result = 1; // right
 } else if (digitalRead(bUp)==LOW) {
   result = 2; // up
 } else if (digitalRead(bDown)==LOW) {
   result = 3; // down
 } else if (digitalRead(bLeft)==LOW) {
   result = 4; // left
 }
 return result;
}

// If there are common usage instructions on more than 1 of your menu items you can call this function from the sub
// menus to make things a little more simplified. If you don't have common instructions or verbage on multiple menus
// I would just delete this void. You must also delete the drawInstructions()function calls from your sub menu functions.
void drawInstructions() {
 lcd.setCursor(0, 1); // Set cursor to the bottom line
 lcd.print("Use ");
 lcd.print(byte(1)); // Up arrow
 lcd.print("/");
 lcd.print(byte(2)); // Down arrow
 lcd.print(" buttons");
}

void menuItem1() { // Function executes when you select the 1st item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(1, 0);
 lcd.print("wybrano opcje 1");
 lcd.setCursor(1, 1);
 lcd.print("1111111");


 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {

     
//napis matrix led---------------------------------------------------  
   byte c;
   delay(100);
   m.shiftLeft(false, true);
   printStringWithShift(string1, 80);  // Send scrolling Text
//napis matrix led---------------------------------------------------  

 
     delay(100);
     readKey = analogRead(0);      
   }
   button = evaluateButton(readKey);

   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem2() { // Function executes when you select the 2nd item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(1, 0);
 lcd.print("wybrano opcje 2");
 lcd.setCursor(1, 1);
 lcd.print("2222222");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {

//napis matrix led---------------------------------------------------  
   byte c;
   delay(100);
   m.shiftLeft(false, true);
   printStringWithShift(string2, 80);  // Send scrolling Text
//napis matrix led---------------------------------------------------  
     
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem3() { // Function executes when you select the 3rd item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 3");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem4() { // Function executes when you select the 4th item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 4");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem5() { // Function executes when you select the 5th item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 5");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem6() { // Function executes when you select the 6th item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 6");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem7() { // Function executes when you select the 7th item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 7");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem8() { // Function executes when you select the 8th item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 8");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem9() { // Function executes when you select the 9th item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 9");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}

void menuItem10() { // Function executes when you select the 10th item from main menu
 int activeButton = 0;

 lcd.clear();
 lcd.setCursor(3, 0);
 lcd.print("Sub Menu 10");

 while (activeButton == 0) {
   int button;
   readKey = analogRead(0);
   if (readKey < 790) {
     delay(100);
     readKey = analogRead(0);
   }
   button = evaluateButton(readKey);
   switch (button) {
     case 4:  // This case will execute if the "back" button is pressed
       button = 0;
       activeButton = 1;
       break;
   }
 }
}
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości