Closed bayunp89 closed 5 years ago
Hello, your problem is the delay() function in your diaktifkan() function and in other functions.
The arduino IDE have an example under "digital"->"blink without delay". Look into the example and learn how you can create your program without delays. At the moment your millis() check have no protection against an overrun. https://www.arduino.cc/en/tutorial/BlinkWithoutDelay
Please build your complete program without any delay functions and you can see how it works together :-)
For example in your mFunc_para function you have set an interval to call this function every 100 ms. You can create a variable which counts the calls. Set the variable in the function setup to zero like in this example:
uint8_t g_your_counter_variable = 0;
// =====================================================================
void mFunc_para(uint8_t param)
// *********************************************************************
{
if(LCDML.FUNC_setup()) // ****** SETUP *********
{
//char buf[20];
//sprintf (buf, "Mode : %d", param);
LCDML.FUNC_setLoopInterval(100); // starts a trigger event for the loop function every 100 milliseconds
g_your_counter_variable = 0;
}
if(LCDML.FUNC_loop()) // ****** LOOP *********
{
// For example
switch(param)
{
case 1:
// do something
if(g_your_counter_variable == 0)
{
lcd.setCursor(0,0);
lcd.print(F("Berhasil"));
lcd.setCursor(0,1);
lcd.print(F("Diaktifkan"));
digitalWrite(ledPin,HIGH);
}
else if(g_your_counter_variable >= 9)
{
//diaktifkan();
LCDML.FUNC_goBackToMenu();
}
break;
case 2:
// do something
if(g_your_counter_variable == 0)
{
lcd.setCursor(0,0);
lcd.print(F("Berhasil"));
lcd.setCursor(0,1);
lcd.print(F("Dinoaktifkan"));
}
else if(g_your_counter_variable >= 9)
{
//digitalWrite(relay1,HIGH);
//digitalWrite(relay2,HIGH);
digitalWrite(ledPin,LOW);
LCDML.FUNC_goBackToMenu();
}
break;
default:
// do nothing
break;
}
// Increment the counter variable by 1
g_your_counter_variable++;
if (LCDML.BT_checkAny()) // check if any button is pressed (enter, up, down, left, right)
{
LCDML.FUNC_goBackToMenu(); // leave this function
}
}
if(LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
}
}
hi i am from indonesia
I need help with my code,i combine the menu with Fade Light LED. but when the LED run,the other menu not run until the fade finished.
sorry with my english,i'm newbie hear:). this is my code Menu_Aquarium.zip