Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [loop]

The tag has no usage guidance.

0
votes
2answers
35 views

Confusion between switch and if?

Following code is to control two LEDs for on and off by two dedicated push buttons. I have used if() for each condition and I was not comfortable writing this code, as I could feel, it can be better ...
0
votes
1answer
21 views

ESP32 stops looping after 2 loops

My code: https://pastebin.com/UmdK33U2 I made a menu so I can send commands. First I connect to the wifi and then I send the command to send a request. Then when it detects the key datos(); goes ...
0
votes
3answers
34 views

If a condition is ever met I want to run a loop permanently

I am trying to run an LED to do SOS in morse code if a temperature is over 20 C and motion is detected, but I want it to continue doing SOS even after the motion goes away or the temperature comes ...
0
votes
1answer
17 views

Global Variable does not Change when Value is set within Boolean Function

I have a boolean function which contains a string. In my main project this string is extracted from a website using an ESP8266 which is compatible with the Arduino IDE. I need to convert this string ...
0
votes
1answer
48 views

If/Else Statements on Arduino not executing

I have a bit of code below, the problem is only the first 'if' statement will execute when called on. When I call on u, q, or any of the other if statements it will go straight to the else and not ...
0
votes
1answer
83 views

Button to exit a running loop

I have a very basic circuit setup: A button connected to pin 2 An LED connected to pin 9 Desired Functionality: When the button is pressed, the user can toggle through 4 LED patterns. The ...
0
votes
4answers
67 views

help with a loop

I recently got into programing and I'm making an alarm. I cant figure out how to make a buzzer loop. I have two blinking LED's and two fading ones. Now I plan to have sound and it won't work. It only ...
1
vote
4answers
77 views

for() loop doesn't seem to break?

So I'm quite new to the whole Arduino coding but constructed a sketch that does work, but I think it doesn't work properly. So I'd love to get some advice on how to improve it. This script is ...
0
votes
2answers
56 views

For loop broken? [closed]

This is a pseudo code from my LED cube project void loop(){ //switch( map(constrain(analogRead(pt),10,1020),10,1020,1,4)); - for select pattern //show(1); for(lp=128;lp>=1;lp = lp/2){ ...
3
votes
1answer
81 views

Correct way of having loop end when required?

I'm brand new to Arduinos. I'm currently trying to modify a script from here which at the moment, simply turns an LED on or off depending on which HTTP GET request it receives. However, I want to ...
0
votes
1answer
24 views

Variable that holds the users input doesn't empty itself, so the program only works once

This code seems to function, but only works once before I need to press the reset button. Otherwise, it repeats the same error message. It might have something to do with emptying the String variable. ...
0
votes
0answers
31 views

Main loop not executing after calling other void function

I am using Teensy 3.2/ Arduino micro to develop an air quality monitoring system. The principle is quite easy. Get the data from the sensors, (PM 2.5 ,CO2) , Send it back to Teensy to calculate one ...
0
votes
2answers
137 views

Arduino - Button to start / stop loop

So basically I'm trying to create a device where when I push a button it starts a loop. When I push this button again, it stops the loop. Right now I have it logged to serial. It starts up correctly ...
0
votes
1answer
161 views

ESP8266 Stops Working After A While (Unknown Problem)

have an esp8266. i'm trying to create a DDNS updater. it has to wait 5 min then do a GET request to a URL. Here's my code: /* Code For DNS Updater.*/ #include <ESP8266WiFi.h> #include <...
0
votes
1answer
44 views

Averaging input from multiple input over a fixed amount of time (estimated)

I am trying to average input values for a number of inputs and have it then store those averages into a string to write to a txt doc on a sd card. I am using: // read 6 sensors and append to the ...
0
votes
2answers
92 views

Arduino Switching Between Loops IR Remote

I've been working on an LED strip project. However, I've come to a stand still at the moment. Within the program I am wanting to assign different lighting effects to each button on my IR remote. I am ...
0
votes
1answer
63 views

How to stop sending the last received char of UART echo function?

I developed a code for uart based ISR with linear buffers, the problem is that it keep sending the last received char in Arduino IDE. Here's the application code: #include "uart_new.h" void setup() ...
0
votes
1answer
134 views

Breaking out of a while loop using IR remote for neopixel

I've been piecing together various lighting effects. I am wanting to have each lighting effect loop until another button is pressed to trigger another lighting effect. I've come to a bit of ...
0
votes
1answer
51 views

Optimal and Save Water Pump Control

I'm using an Arduino Micro, a 12 V water pump and a print relay to water a plant. A water level switch monitors the the water tank to make sure the water pump does not run dry. I tried different ...
1
vote
2answers
120 views

How can I loop my code? For example after 30 minutes?

So I have this code which records the temperature and humidity using a DHT22 sensor. After it get's the values it then sends it to a webpage using PHP $_GET method, where that gets imported into a DB ...
0
votes
1answer
53 views

Should I use a loop instead of an If statement?

I have a simple sketch that tests input from 2 touch sensors and outputs to 2 relays (if a sensor is touched, trigger the respective momentary relay). It has been a bit quirky to say the least. ...
1
vote
1answer
138 views

How to stop a loop when using attachInterrupt to catch the change of a button

This what the program does: There is 1 button to start/stop the engine, when the motor is running the green LED will go on, when stopped the red LED is on. The second button is used to change ...
1
vote
2answers
27 views

put_index = (put_index + 1) % 100; [closed]

Can someone interpret the code in the Title line for me? Specifically the function of the "%" sign? It is a line having to do with a 100 element circular buffer.
1
vote
0answers
47 views

Storing random and different values of millis() while inside a loop? [closed]

Is it possible to store a value of time while you're inside a loop? Entertain the condition: if (condition && value > 0) { timeTrans = millis() + 2000; timeTrans - millis() = value; } ...
0
votes
2answers
79 views

Is a variable declaration inside a loop static declaration or dynamic?

while(condition){ Object object = new Object(); } So my question is, will each iteration would create a different object in different memory location or it will overwrite the once created object ...
0
votes
2answers
111 views

What's wrong with infinite loops inside loop()?

I wanted to run the following code as something similar to Tone or pwm. However for some reason that I am unable to seek it doesn't work. #define WAIT 3200UL void setup() { DDRB |= B00000001; // ...
0
votes
1answer
64 views

Problem with action that should happen in loop(continuously)

I’m using WeMos D1 R2 and latest Blynk library and app. I am also using Arduino IDE 1.6.13. I am trying to read a button from the app, which works fine, but i want to read it continuously. Through the ...
0
votes
0answers
118 views

Loop being restarted before it finishes?

I have a Loop process that does various I/O and delay operations and also logs to the serial port so that we can review the activity. We what I think is the loop being interrupted. Normally the ...