Questions tagged [loop]

The tag has no usage guidance.

29 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
44 views

Two LED Patterns Task Controlled by GUI

I am very new to Arduino and coding/programing. I set a task for myself to make a simple circuit of 5 LEDs controlled by pins 2, 4, 8, 11, 12. I want to be able to make two different pattern for the ...
1
vote
0answers
29 views

How to make my sensor reads when i pressed the button

Hi I'm making a digital fare meter, I have a problem in how my sensor reads when I'd pressed the button(single tap). I need the sensor to read once I pressed the button because when I press the button ...
1
vote
0answers
56 views

Setting a fixed receiver frequency RDA5807m

I am using the receiver RDA5807m, but I do NOT need to switch the frequency and other parameters during operation. I noticed that the module continues to work when the programming pins are ...
1
vote
0answers
59 views

Infared: some controllers send code into infinite loop

I have a piece of code that captures input from infrared and spits it out to the serial port. When I use it with a simple controller that comes with a typical kit, it receives the infrared code just ...
1
vote
0answers
33 views

how to control 2 sensor and 3 relay with fuzzy

i'm using fuzzy to decide how long the relay on pump on and i got some trouble for it he just looping on relay how should i do thats my code //---------Fuzzy 2.1 prelauch---------- //-----iNPUT ...
1
vote
0answers
34 views

My circuit is being goofy with regards to my PIR sensor

Here is the code I've written so far. I am making a circuit with a couple of motors and 3 sensors. My plan is for the PIR Motion sensor, distance sensor, and photoresistor to tell the motors to stop ...
1
vote
1answer
67 views

Looking to optimize this code and add a loop

So I want to optimize this code and add a loop to the two red LEDs. The process is green LED is flashing, press button, yellow LED blink for 3 secs and then alternate flashing between the two red LEDs ...
1
vote
1answer
76 views

Wifi strength Automation . Help. Noobie here

#include <ESP8266WiFi.h> const char *SSID = "mr_lazy_boei"; const char *pass = "usalusal"; WiFiClient client; // Relay pin number int ignition=2; int self=0; // Return ...
1
vote
1answer
220 views

Mega 2560 does not play audio file when I want. It plays when the first condition is met, but not the other

Okay, so I am making a jewelry box for my niece that will spin a necklace holder with a stepper motor, play an audio file and turn on LED lights. I am using an Arduino MEGA 2560. The flow is this: ...
1
vote
0answers
43 views

Code is not looping correctly when running on battery

static const int dry = 570; static const int wet = 225; static const int RELAY = 2; static const unsigned long DELAY_1_S = 1000; static const unsigned long DELAY_1_MINUTE = DELAY_1_S * 60; static ...
1
vote
1answer
81 views

Breaking out of the arduino fingerprint enroll loop

I am using the Arduino's Adafruit Finger Sensor library, and it has an example to enroll a fingerprint. I want it to enroll one print and exit/break out of the loop because it currently enrolls a user,...
1
vote
0answers
175 views

Looping a defined function to show live variables printed on OLED screen

I have started a thread on the Arduino forum. If someone could have a look at the thread and give me some help either here or there that would be great. (I don't want to have to add all the ...
1
vote
3answers
81 views

How long does my digital pulse need to be for it to be read?

I have the following really simple code. On every iteration it'll read the first pin, and if it's high - do some serial IO. Then do the same with the second pin. Nice and simple, works during my tests....
1
vote
0answers
63 views

While Loop does not stop when condition is false

Here's the code: void loop() { while (1 == 1) { ObsLeft(); while (SeeLeft < 50 || SeeLeft == 50) { Urong(); ObsLeft(); if (SeeLeft > 50) { Hinto; ...
1
vote
0answers
94 views

Stepper motor only rotates once in a loop?

I am quite new to this , I am trying to program two motors , aStepper and bStepper. I want the program to rotate aStepper then rotate the bStepper and when that is done rotate aStepper again , and ...
1
vote
0answers
230 views

Stuck in a loop when reading from EEPROM, works if I clear it first

EDIT: The problem was caused by storing a pointer in the EEPROM. Thanks to @KIIV for helping out Sorry for the enormous of wall of text, I'm trying to pare it down a bit. I have two Arduino Megas ...
1
vote
0answers
212 views

analogWrite and For Loop Bug

I wrote the following code that outputs a packet data structure bit by bit. I do this using two for loops. These two for loops should always terminate, but the presence of analogWrite() makes them ...
1
vote
0answers
37 views

Arduino and NodeMCU problem with wifi conecction

Hello guys I am beginner with micro controllers but I am trying to make a simple IoT with Arduino and NodeMCU as WiFi. I was using this tutorial and code https://www.electronicshub.org/wifi-controlled-...
1
vote
0answers
28 views

Loop failure after unset amount of time

I am building an art piece that takes in input from three rotary encoders and two buttons. and outputs data to a large neopixel display and 2 large 4 digit seven segment displays. The displays are ...
1
vote
0answers
77 views

Does not execute code on loop;only run code of set up

only display this: ARDUMOTIVE ArduinoBased compassn.Compass Michalis Vas. nothing else. I tried another Arduino Uno, Mega, Nano, but execute only set up. Display is working.No compiler errors.Sketch ...
0
votes
1answer
60 views

Exit from for function after detecting obstacles

#include <HCSR04.h> int red = 13; int green = 12; int blue = 11; int trigger = 9; int echo = 8; int halt; void setup(){ pinMode(red, OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT)...
0
votes
2answers
180 views

Is there a way to make a function take an exact number of clock cycles?

Is it possible to use something like a compiler directive to pad a function with do nothing instructions so that as you add lines of code or take them away it always executes in the same amount of ...
0
votes
0answers
722 views

Break a while loop with a push button (AccelStepper.h)

Disclaimer: This is my first Arduino project. Background: I am building a "rapunzel tower" lantern for my daughter: the witch pays a visit to Rapunzel meanwhile my daughter can read a book (or still ...
0
votes
1answer
129 views

Wire SlaveReceiver : will the registered function in onRecieve interrupt/conflict with loop block?

I am currently researching on I2C, and I made a configuration that has MasterWriter that transmits data to a SlaveReceiver that will store the data received from Master, into an SD card, and then ...
0
votes
1answer
122 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 ...
0
votes
0answers
153 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 ...
-1
votes
1answer
122 views

Infinite loop serial.readString()

Ok, this is my code: int rosso = 13; int verde = 12; int blu = 11; int count = 0; String command_on, command_off; String s; String enough = "stop"; void setup(){ pinMode(rosso, OUTPUT); pinMode(...
-1
votes
1answer
47 views

ARDUINO flashing lights

I'm making a circuit with my Arduino so that when it receives a '1' or '2' or 'a' it turns on or off the LEDS. But I wanted the lights to flash and do not know how to do loops in loops or if that's ...
-1
votes
2answers
201 views

Setting a pin to a continous wave output

Is there any way in Arduino to set a particular pin(pwm or not) to just generate a square wave out of the desired pin? For instance, I want to have two pins on my Arduino Uno that output two square ...