I want to stop function when it running using button. so I tried using do while loop like tat.
void loop(){
while
(button == false);
do{
// run function1. It take few second because use delay function.
}
if (button == true)
{
function2()
// function2 running. take few seconds
}
}
void function1 (){
// function 1 code
}
void function2 (){
// function 2 code
}
I want run function 2 when running function 1 using push button. Function 1 should be break when press button. case is both functions use few second to execute and cannot match checking button state movement and button pressing movement.
It can using interrupt but when release button it will again run function1 so it cannot use for my sketch. how can solve it. please give your idea to fix my problem.
Apologies for grammar mistakes because English is not my mother tongue.
thankyou.
I suspect that you think this section is a complete 'do-while' statement. But it doesn't follow the language syntax rules at all. Thus your intention (whatever it is) is completely mangled.
while
(button == false);
do{
// run function1. It take few second because use delay function.
}
Hi indula,
it is OK trying to practise another language on your hobby.
In this case I don't understand what you want to say.
I recommend that you use google-translate and write all what you want to write in your native language.
From your username google-translate claims to reconginze Hindi.
So here is the same text in Hindi as a demonstration how well google-translate is.
The writing-style of a google-translation is not brilliant. But vrey good understandable.
Give google-translate a try.
best regards Stefan
हाय इंदुला,
अपने शौक पर दूसरी भाषा का अभ्यास करना ठीक है।
इस मामले में मुझे समझ नहीं आ रहा है कि आप क्या कहना चाहते हैं।
मेरा सुझाव है कि आप Google- अनुवाद का उपयोग करें और जो आप अपनी मूल भाषा में लिखना चाहते हैं वह सब लिखें।
अपने उपयोगकर्ता नाम Google-Translate में हिंदी को पुनः प्राप्त करने का दावा करता है।
तो यहाँ पर हिंदी में एक ही टेक्स्ट है कि प्रदर्शन कितना अच्छा है, गूगल-ट्रांसलेट।
गूगल-अनुवाद की लेखन-शैली शानदार नहीं है। लेकिन अच्छे अच्छे समझ में आता है।
Google-Translate को आज़माएँ।
सबसे अच्छा संबंध है स्टीफन
haay indula,
apane shauk par doosaree bhaasha ka abhyaas karana theek hai.
is maamale mein mujhe samajh nahin aa raha hai ki aap kya kahana chaahate hain.
mera sujhaav hai ki aap googlai- anuvaad ka upayog karen aur jo aap apanee mool bhaasha mein likhana chaahate hain vah sab likhen.
apane upayogakarta naam googlai-translatai mein hindee ko punah praapt karane ka daava karata hai.
to yahaan par hindee mein ek hee tekst hai ki pradarshan kitana achchha hai, googal-traansalet.
googal-anuvaad kee lekhan-shailee shaanadaar nahin hai. lekin achchhe achchhe samajh mein aata hai.
googlai-translatai ko aazamaen.
sabase achchha sambandh hai steephan
Thank you very much for your ideas. Yes it seems like push button working as toggle switch. when change state of toggle switch it keeps state when code check state (switch == true) then while or do while code can change. but if we push the button when function running in somewhere in middle part it cannot be store button state changes until check the button states.
function(){
while (button == false)
{
function beginning.... (0s)
///// button press when function running in 3s and it release when 3.5 s
function middle....(5s)
function last.....(10s)
}
}
as mentioned example above, code run in 10 seconds. if I push the button in when code in 3 s, change button state but code take next 7 s for check button state. but that time button state also became previous sate because when 3.5s button was released. so It is a futile action in this case.
I hope you have clearly understood my question. So I expect some answer to this problem. I think something can be do using Millis() but Because I'm still a fan of Arduino. So hope your valuable comments. Again apologize for grammar mistakes