Problém s vyvoláním funkce

Nedaří se vám s projektem a nenašli jste vhodné místo, kde se zeptat? Napište sem.
Pravidla fóra
Tohle subfórum je určeno pro konzultaci ucelených nápadů, popřípadě řešení komplexnějších projektů, které opravdu není možné rozdělit na menší části.
Většinu problémů jde rozdělit na menší a ptát se na ně v konkrétních subfórech.
Odpovědět
Shaki_O_Neil
Příspěvky: 2
Registrován: 12 bře 2021, 16:18
Reputation: 0

Problém s vyvoláním funkce

Příspěvek od Shaki_O_Neil » 12 bře 2021, 16:25

Zdravím, začínám s Arduinem a rozhodl jsem se vyrobit bombu pro airsoft, nedaří se mi, ale správně spustit časování. pokaždé, když sputím odpočet pomocí #, zobrazí se nastavený čas pro odpočet a tím to hasne. MOhl by mi někdo poradit co dělám špatně? Děkuji

Kód: Vybrat vše

#include <Tasker.h>
Tasker tasker;

#include <Key.h>
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad keyPad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

uint8_t load[8] = {0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f};

int readVcc() {
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
  ADMUX = _BV(MUX5) | _BV(MUX0) ;
#else
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif

  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA, ADSC)); // measuring

  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
  uint8_t high = ADCH; // unlocks both

  long result = (high << 8) | low;

  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}

int Hours = 00;
int Minutes = 00;
int Seconds = 00;
int trycount = 0;
int keycount = 0;
int i = 0;

int hourstenscode;
int hoursonescode;
int mintenscode;
int minonescode;
int sectenscode;
int seconescode;

long secMillis = 0;
long interval = 1000;

char password[5];
char entered[5];



int red = 10;
int green = 11;
int blue = 12;
int piezo = 13;


void main_screen()
{
  digitalWrite(red, 0);
  digitalWrite(green, 0);
  digitalWrite(blue, 1);


  Serial.begin(9600);

  lcd.begin();
  lcd.backlight();
  digitalWrite(12, 1);
  lcd.createChar(1, load);
  delay(2000);

  readVcc();
  if (readVcc() >= 3800)
  {
    digitalWrite(10, 0);
    digitalWrite(11, 1);
    digitalWrite(12, 0);

    lcd.setCursor(0, 0);
    lcd.print("voltage is:");
    lcd.print(readVcc() / 1000.00);
    lcd.print("V");
    lcd.setCursor(0, 1);
    lcd.print("voltage good!");
    delay(3000);
  }

  if (readVcc() <= 3800)
  {
    digitalWrite(10, 1);
    digitalWrite(11, 0);
    digitalWrite(12, 0);
    lcd.setCursor(0, 0);
    lcd.print("voltage is:");
    lcd.print(readVcc() / 1000.00);
    lcd.print("v");
    lcd.setCursor(0, 1);
    lcd.print("replace battery!");
    delay(3000);
  }
  digitalWrite(12, 1);
  digitalWrite(10, 0);
  digitalWrite(11, 0);
  lcd.clear();
  lcd.setCursor(1, 0);
  lcd.print("S.F.A presents");
  delay(1000);
  lcd.display();
  delay(500);
  lcd.noDisplay();
  delay(500);
  lcd.display();
  delay(500);
  lcd.noDisplay();
  delay(500);
  lcd.display();
  delay(2000);

  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Shaki's bomb");
  delay(2000);
  lcd.setCursor(1, 1);
  lcd.print("Loading system");
  delay(2000);
  lcd.clear();
  lcd.setCursor(1, 0);
  lcd.print("Loading system");
  delay(1000);
  lcd.setCursor(0, 1);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(200);
  lcd.write(1);
  delay(1000);
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("WELCOME!");
  delay(2000);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("SELECT GAME");
  lcd.setCursor(0, 1);
  lcd.print("-A-");
  lcd.setCursor(7, 1);
  lcd.print("-B-");
  lcd.setCursor(13, 1);
  lcd.print("-C-");
}
void set_a() {
  tone(piezo, 1200, 80);
  digitalWrite(10, 0);
  digitalWrite(11, 0);
  digitalWrite(12, 1);
  delay(100);
  digitalWrite(12, 0);
  delay(100);
  digitalWrite(12, 1);
  delay(100);
  digitalWrite(12, 0);
  delay(100);
  digitalWrite(11, 1);
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("-GAME A-");
  lcd.setCursor(2, 1);
  lcd.print("Bomb defuse");
  delay(1000);
  game_a();
  game_a_start();
}
void set_b() {
  tone(piezo, 1200, 80);
  digitalWrite(10, 0);
  digitalWrite(11, 0);
  digitalWrite(12, 1);
  delay(100);
  digitalWrite(12, 0);
  delay(100);
  digitalWrite(12, 1);
  delay(100);
  digitalWrite(12, 0);
  delay(100);
  digitalWrite(11, 1);
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("-GAME B-");
  lcd.setCursor(1, 1);
  lcd.print("Counter-strike");
}
void set_c() {
  tone(piezo, 1200, 80);
  digitalWrite(10, 0);
  digitalWrite(11, 0);
  digitalWrite(12, 1);
  delay(100);
  digitalWrite(12, 0);
  delay(100);
  digitalWrite(12, 1);
  delay(100);
  digitalWrite(12, 0);
  delay(100);
  digitalWrite(11, 1);
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("-GAME C-");
  lcd.setCursor(3, 1);
  lcd.print("Domination");
}
void set_d() {
  tone(piezo, 2400, 1000);
  digitalWrite(11, 0);
  digitalWrite(10, 1);
  delay(100);
  digitalWrite(10, 0);
  delay(100);
  digitalWrite(10, 1);
  delay(100);
  digitalWrite(10, 0);
  digitalWrite(11, 0);
  digitalWrite(12, 1);
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("-BACK-");
  delay(1000);
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("SELECT GAME");
  lcd.setCursor(0, 1);
  lcd.print("-A-");
  lcd.setCursor(7, 1);
  lcd.print("-B-");
  lcd.setCursor(13, 1);
  lcd.print("-C-");
}

void type_game()
{
  char button = keyPad.getKey();

  if (button == 'A') {
    set_a();
  }


  if (button == 'B') {
    set_b();
  }
  if (button == 'C') {
    set_c();
  }

  if (button == 'D') {
    set_d();
  }
}
void game_a() {
  digitalWrite(10, 0);
  digitalWrite(11, 1);
  digitalWrite(12, 0);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Bomb activated!");
  lcd.setCursor(0, 1);
  lcd.print("Enter Code:");
  while (keycount < 5)
  {
    lcd.setCursor(keycount + 11, 1);
    lcd.blink();
    char armcode = keyPad.getKey();
    armcode == NO_KEY;
    if (armcode != NO_KEY)
    {
      if ((armcode != '*') && (armcode != '#'))
      {
        lcd.print(armcode);
        tone(13, 5000, 100);
        password[keycount] = armcode;
        keycount++;
      }
    }
  }

  if (keycount == 5)
  {
    delay(500);
    lcd.noBlink();
    lcd.clear();
    lcd.home();
    lcd.print("Disarm Code is: ");
    lcd.setCursor(6, 1);
    lcd.print(password[0]);
    lcd.print(password[1]);
    lcd.print(password[2]);
    lcd.print(password[3]);
    lcd.print(password[4]);
    delay(3000);
    lcd.clear();
  }
  lcd.setCursor(0, 0);
  lcd.print("Timer: HH:MM:SS");
  lcd.setCursor(0, 1);
  lcd.print("SET:   :  :");
  keycount = 5;

  while (keycount == 5)
  {
    char hourstens = keyPad.getKey();
    lcd.setCursor(5, 1);
    lcd.blink();
    if (hourstens >= '0' && hourstens <= '9')
    {
      hourstenscode = hourstens - '0';
      tone(13, 5000, 100);
      lcd.print(hourstens);
      keycount++;
    }
  }

  while (keycount == 6)
  {
    char hoursones = keyPad.getKey();
    lcd.setCursor(6, 1);
    lcd.blink();
    if (hoursones >= '0' && hoursones <= '9')
    {
      hoursonescode = hoursones - '0';
      tone(13, 5000, 100);
      lcd.print(hoursones);
      keycount++;
    }
  }

  while (keycount == 7)
  {
    char mintens = keyPad.getKey();
    lcd.setCursor(8, 1);
    lcd.blink();
    if (mintens >= '0' && mintens <= '9')
    {
      mintenscode = mintens - '0';
      tone(13, 5000, 100);
      lcd.print(mintens);
      keycount++;
    }
  }

  while (keycount == 8)
  {
    char minones = keyPad.getKey();
    lcd.setCursor(9, 1);
    lcd.blink();
    if (minones >= '0' && minones <= '9')
    {
      minonescode = minones - '0';
      tone(13, 5000, 100);
      lcd.print(minones);
      keycount++;
    }
  }

  while (keycount == 9)
  {
    char sectens = keyPad.getKey();
    lcd.setCursor(11, 1);
    lcd.blink();
    if (sectens >= '0' && sectens <= '9')
    {
      sectenscode = sectens - '0';
      tone(13, 5000, 100);
      lcd.print(sectens);
      keycount = 10;
    }
  }

  while (keycount == 10)
  {
    char secones = keyPad.getKey();
    lcd.setCursor(12, 1);
    lcd.blink();
    if (secones >= '0' && secones <= '9')
    {
      seconescode = secones - '0';
      tone(13, 5000, 100);
      lcd.print(secones);
      keycount = 11;
    }
  }

  if (keycount == 11);
  {
    Hours = (hourstenscode * 10) + hoursonescode;
    Minutes = (mintenscode * 10) + minonescode;
    Seconds = (sectenscode * 10) + seconescode;
    delay(100);
    lcd.noBlink();
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Timer set at:");
    if (Hours >= 10)
    {
      lcd.setCursor (7, 1);
      lcd.print (Hours);
    }
    if (Hours < 10)
    {
      lcd.setCursor (7, 1);
      lcd.write ("0");
      lcd.setCursor (8, 1);
      lcd.print (Hours);
    }
    lcd.print (":");

    if (Minutes >= 10)
    {
      lcd.setCursor (10, 1);
      lcd.print (Minutes);
    }
    if (Minutes < 10)
    {
      lcd.setCursor (10, 1);
      lcd.write ("0");
      lcd.setCursor (11, 1);
      lcd.print (Minutes);
    }
    lcd.print (":");

    if (Seconds >= 10)
    {
      lcd.setCursor (13, 1);
      lcd.print (Seconds);
    }

    if (Seconds < 10)
    {
      lcd.setCursor (13, 1);
      lcd.write ("0");
      lcd.setCursor (14, 1);
      lcd.print (Seconds);
    }
    delay(3000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Press # to arm");
    delay (50);
    keycount = 12;
  }

  while (keycount == 12)
  {
    char armkey = keyPad.getKey();

    if (armkey == '#')
    {
      tone(13, 5000, 100);
      delay(50);
      tone(13, 0, 100);
      delay(50);
      tone(13, 5000, 100);
      delay(50);
      tone(13, 0, 100);
      delay(50);
      tone(13, 5000, 100);
      delay(50);
      tone(13, 0, 100);
      lcd.clear();
      lcd.print ("Bomb Armed!");
      lcd.setCursor(0, 1);
      lcd.print("Countdown start");
      delay(3000);
      lcd.clear();
      keycount = 0;
    }
  }
}
void timer(void)
{
  Serial.print(Seconds);
  Serial.println();
  if (Hours <= 0)
  {
    if ( Minutes < 0 )
    {
      lcd.noBlink();
      lcd.clear();
      lcd.home();
      lcd.print("The Bomb Has ");
      lcd.setCursor (0, 1);
      lcd.print("Exploded!");

      while (Minutes < 0)
      {
        digitalWrite(10, 1);
        tone(13, 7000, 100);
        delay(100);
        digitalWrite(10, 0);
        tone(13, 7000, 100);
        delay(100);
        digitalWrite(11, 1);
        tone(13, 7000, 100);
        delay(100);
        digitalWrite(green, 0);
        tone(13, 7000, 100);
        delay(100);
        digitalWrite(12, 1);
        tone(13, 7000, 100);
        delay(100);
        digitalWrite(12, 0);
        tone(13, 7000, 100);
        delay(100);
      }
    }
  }
  lcd.setCursor (0, 1);
  lcd.print ("Timer:");

  if (Hours >= 10)
  {
    lcd.setCursor (7, 1);
    lcd.print (Hours);
  }
  if (Hours < 10)
  {
    lcd.setCursor (7, 1);
    lcd.write ("0");
    lcd.setCursor (8, 1);
    lcd.print (Hours);
  }
  lcd.print (":");

  if (Minutes >= 10)
  {
    lcd.setCursor (10, 1);
    lcd.print (Minutes);
  }
  if (Minutes < 10)
  {
    lcd.setCursor (10, 1);
    lcd.write ("0");
    lcd.setCursor (11, 1);
    lcd.print (Minutes);
  }
  lcd.print (":");

  if (Seconds >= 10)
  {
    lcd.setCursor (13, 1);
    lcd.print (Seconds);
  }

  if (Seconds < 10)
  {
    lcd.setCursor (13, 1);
    lcd.write ("0");
    lcd.setCursor (14, 1);
    lcd.print (Seconds);
  }

  if (Hours < 0)
  {
    Hours = 0;
  }

  if (Minutes < 0)
  {
    Hours --;
    Minutes = 59;
  }

  if (Seconds < 1)
  {
    Minutes --;
    Seconds = 59;
  }

  if (Seconds > 0)
  {
    unsigned long currentMillis = millis();

    if (currentMillis - secMillis > interval)
    {
      tone(13, 7000, 50);
      secMillis = currentMillis;
      Seconds --;
      digitalWrite(10, 1);
      delay(10);
      digitalWrite(10, 0);
      delay(10);
    }
  }
}
void game_a_start(void) {
  timer();
  char disarmcode = keyPad.getKey();

  if (disarmcode == '*')
  {
    tone(13, 5000, 100);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Code: ");

    while (keycount < 5)
    {
      timer();

      char disarmcode = keyPad.getKey();
      if (disarmcode == '#')
      {
        tone(13, 5000, 100);
        keycount = 0;
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Code: ");
      }
      else if (disarmcode != NO_KEY)
      {
        lcd.setCursor(keycount + 7, 0);
        lcd.blink();
        lcd.print(disarmcode);
        entered[keycount] = disarmcode;
        keycount++;
        tone(13, 5000, 100);
        delay(100);
        lcd.noBlink();
        lcd.setCursor(keycount + 6, 0);
        lcd.print("*");
        lcd.setCursor(keycount + 7, 0);
        lcd.blink();
      }
    }

    if (keycount == 5)
    {
      if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3])
      {
        lcd.noBlink();
        lcd.clear();
        lcd.home();
        lcd.print("Bomb Defused!");
        lcd.setCursor(0, 1);
        lcd.print("Great job!");
        keycount = 0;
        digitalWrite(11, 1);
        delay(15000);
        lcd.clear();
        lcd.setCursor(0, 1);
        lcd.print("Reset the Bomb");
        delay(1000000);
      }
      else
      {
        lcd.noBlink();
        lcd.clear();
        lcd.home();
        lcd.print("Wrong Password!");
        trycount++;

        if (Hours > 0)
        {
          Hours = Hours / 2;
        }

        if (Minutes > 0)
        {
          Minutes = Minutes / 2;
        }
        if (Seconds > 0)
        {
          Seconds = Seconds / 2;
        }
        if (trycount == 2)
        {
          interval = interval / 10;
        }
        if (trycount == 3)
        {
          Minutes = Minutes - 59;
          Hours = Hours - 59;
          Seconds = Seconds - 59;
        }
        delay(1000);
        keycount = 0;
      }
    }
  }

}
void setup() {

  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);

  main_screen();

}
void loop() {
  type_game();
}

PetrB
Příspěvky: 141
Registrován: 20 čer 2018, 13:39
Reputation: 0

Re: Problém s vyvoláním funkce

Příspěvek od PetrB » 12 bře 2021, 23:46

Ahoj,
proč Ti to takto končí jsem zatím nenašel, ale měl bych pár připomínek ke kódu.
Type_game bych napsal spíše takto:

Kód: Vybrat vše

void type_game()
{
    switch case(keyPad.getKey()) {
    case 'A':
             set_a();
             break;
    case 'B':
             set_a();
             break;
    case 'C':
             set_a();
             break;
    case 'D':
             set_a();
             break;
    }
}
Přijde mi to přehlednější, lépe se doplňují další varianty.

Pak jsem procházel game_a. Pro výpis na řádek bych si definoval rutinu
něco jako

Kód: Vybrat vše

void pisRadek(int vCislo,String vText,bool vClear = false) {
 if (vClear) lcd.clear();
 lcd.setCursor(0,vCislo);
 lcd.print(vCo);
}
Obecně mi přijde, že moc nepoužíváš členění do rutin. Kód je pak méně přehledný a hůře se udržuje a ve finále je i větší.

Pak mne zarazilo v první smyčce

Kód: Vybrat vše

   while (keycount < 5)
    {
        lcd.setCursor(keycount + 11, 1);
        lcd.blink();
        char armcode = keyPad.getKey();
        armcode == NO_KEY; --??Proč??
        if (armcode != NO_KEY)
        {
            if ((armcode != '*') && (armcode != '#'))
            {
                lcd.print(armcode);
                tone(13, 5000, 100);
                password[keycount] = armcode;
                keycount++;
            }
        }
    }
Proč naprázdno testuješ armcode na NO_KEY? Když hned zatím je test, zda je to cokoliv jiného než no key (to bych pochopil).

A hned za touhle smyčkou máš

Kód: Vybrat vše

   if (keycount == 5)  --??Zbytečné, když horní smyčka končí při keycount=5
    {
        delay(500);
        lcd.noBlink();
        lcd.clear();
        lcd.home();
        lcd.print("Disarm Code is: ");
        lcd.setCursor(6, 1);
        lcd.print(password[0]);
        lcd.print(password[1]);
        lcd.print(password[2]);
        lcd.print(password[3]);
        lcd.print(password[4]);
        delay(3000);
        lcd.clear();
    }
Podmínka je podle mne zbytečná, když předchozí smyčka nemůže končit jinak než keycount==5

A pak máš "výbornou sekci", kde se jedna věc opakuje 6x a to mne trochu drásá

Kód: Vybrat vše

    keycount = 5;     --??Tady nic jiného být nemůže
--1. Opakování
    while (keycount == 5)  --Čeká dokud není zadané první číslo
    {
        char hourstens = keyPad.getKey();
        lcd.setCursor(5, 1);
        lcd.blink();
        if (hourstens >= '0' && hourstens <= '9')  --Zadalo se číslo
        {
            hourstenscode = hourstens - '0';       
            tone(13, 5000, 100);
            lcd.print(hourstens);
            keycount++;                            --Ukonči smyčku
        }
    }
--2. Opakování
    while (keycount == 6)                          --čekej na zadání čísla
    {
        char hoursones = keyPad.getKey();
        lcd.setCursor(6, 1);
        lcd.blink();
        if (hoursones >= '0' && hoursones <= '9')   --Zadalo se číslo
        {
            hoursonescode = hoursones - '0';
            tone(13, 5000, 100);
            lcd.print(hoursones);
            keycount++;                             --Ukonči smyčku 
        }
    }
--3. Opakování
    while (keycount == 7)
    {
        char mintens = keyPad.getKey();
        lcd.setCursor(8, 1);
        lcd.blink();
        if (mintens >= '0' && mintens <= '9')
        {
            mintenscode = mintens - '0';
            tone(13, 5000, 100);
            lcd.print(mintens);
            keycount++;
        }
    }
--4. Opakování
    while (keycount == 8)
    {
        char minones = keyPad.getKey();
        lcd.setCursor(9, 1);
        lcd.blink();
        if (minones >= '0' && minones <= '9')
        {
            minonescode = minones - '0';
            tone(13, 5000, 100);
            lcd.print(minones);
            keycount++;
        }
    }
--5. Opakování
    while (keycount == 9)
    {
        char sectens = keyPad.getKey();
        lcd.setCursor(11, 1);
        lcd.blink();
        if (sectens >= '0' && sectens <= '9')
        {
            sectenscode = sectens - '0';
            tone(13, 5000, 100);
            lcd.print(sectens);
            keycount = 10;
        }
    }
--6. Opakování
    while (keycount == 10)
    {
        char secones = keyPad.getKey();
        lcd.setCursor(12, 1);
        lcd.blink();
        if (secones >= '0' && secones <= '9')
        {
            seconescode = secones - '0';
            tone(13, 5000, 100);
            lcd.print(secones);
            keycount = 11;
        }
    }

To by šlo nahradit něčím třeba takovým

Kód: Vybrat vše

int getNumber(int vCursor) {
int konec=-1;

  lcd.setCursor(vCursor,1);  
  lcd.blink();                     //Tohle nevím, jak se chová, možná to stačí vyvolat jednou vně smyčky

 while (konec<0)
 {
  char a=keyPad.getKey();
  if (a>'0' && a<='9') {
   konec=a-'0';
   tone(13,5000,100);
   lcd.print(a);
  }
 }
 return konec;
}
no a potom by si volal

Kód: Vybrat vše

 hourstenscode=getNumber(5);
 hoursones=getNumber(6);
 ...
Případně by si měl pole a volal by si to

Kód: Vybrat vše

int(6) cas;

...
 for (int i =0; i<6;i++) {
  cas[i]=getNumber(i);
 }
...
Zkus ten kód přepsat (zjednodušit) a třeba to potom uvidíš sám. Případně napiš, kde Ti ten kód asi tak skončí (dobré je třeba si přes Serial vypisovat jednotlivé kroky, aby si viděl, zda tam ten program skutečně došel, nebo zdechl cestou). Takhle to moc nepoznám.

Pb

P.S: úpravy jsem psal z hlavy bez testování a C++ není zrovna moje silná stránka, tak mne ber spíše jako inspiraci.

Shaki_O_Neil
Příspěvky: 2
Registrován: 12 bře 2021, 16:18
Reputation: 0

Re: Problém s vyvoláním funkce

Příspěvek od Shaki_O_Neil » 15 bře 2021, 03:05

Díky za postřehy, mrknu na to.

Odpovědět

Kdo je online

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 19 hostů