![]() In my case, you should be stuck in this while loop until you get "OK" from module. As I see it, thoose 2 statements AND because if you use that function somewhere and you don't get an answer from gsm module like you should, the timeout time gets you free from the do/while loop. So, if switchS is LOW at the start of the while loop, you have an infinite loop. The variable var only changes, when switchS is HIGH. ![]() (You didnt explain this in your question) Currently the variable switchS cannot ever change while the code is in the while loop. This code was written by a person who has 100 times greater programming knowledge than I do so if he made some mistakes whoever used this function including me also did mistakes. I guess you want the while loop to exit, when the switch goes to HIGH. Instead of doing 'If the button is pressed then continue' you need to do 'while the button is not pressed do nothing'. This was just fast copy pasting of the code for testing if my A6 works ok (it arrived yesterday), i didn't have intention to leave the code as it is, I am just trying to learn from examples. The construct you are looking for is called while. I believe the signal is momentarily dropping out and the code over the NRF24 is stopping at the while statement. While (sendATcommand("AT", "OK", 10) = 0) while((answer = 0) & ((millis() - previous) < timeout)) The code seems to run fine, but as soon as there is a missed packet from Arduino 2, Arduino 1 freezes. Begin serial communication with Arduino and A6 My code uses a While loop, a series of memory updates, digital pin manipulations, plot of trace (drawnow) and seems to run smoothly enough. To keep your Arduino loop() running you need to remove these. Is that what you're getting Your question is incomplete. ![]() I would expect this code to print: either 'inside while loop' (if pin 2 is false) or nothing, followed by 'Break.' over and over again. I tried to use this sketch: Serial. 1 The while (1) loop executes once, every time loop () is called, printing or not, depending on the state of pin2. But after a specific time if the user doesnt enter anything it should continue to blink with an preset value. The program asks the user to enter a number how often one LED should blink. stop Blinking Stopped 15010 loop us Latency 5sec max:708 avg:69 sofar max:708 avg:69 max - prt:1676. hi there, I just started to do some basic programming and during the tutorials for ' let a LED blink' a question aroused. To control the Led Blinking, enter either stop or start. Adding two read operations is in the order of 20.04, in practice more like 0.1 s. The loop() time is 0.6ms even while waiting for the user input to timeout if there is no space or comma or CR or NL. Begin serial communication with Arduino and Arduino IDE (Serial Monitor) Maximal sampling time for a single Arduino analog read command is around 0.04 s, in practice Id go minimally 0.05. Code works OK with bigger timeout time, but I am just curios how come it returns to while loop after breaking out of it? #include And after that it returns and just keeps sending "AT" over and over again. It seems to me like mc maneges to break from while loop where it is sending the "AT" because on the serial monitor i see other AT commands that are below the while loop in the setup. ![]() But when I lower timout time (in sendATcommand function) to 10 something happens that I don't understand. So in this code I wrote a while loop for arduino to keep pinging A6 with AT command until it syncronizes the baud rate and returns "OK". if i remove the function call the esp does not crash.I was playing with A6 module and with timeout used in function sendATcommand. When i call " strobeFunction(500, 500, 1024, 10) " The esp8266 crashes after 6 serial prints.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |